I have an array that is called within a wordpress loop. I also need to call the same array on the same page outside of the loop.
The second array always returns blank, and that happens even if I use copy the array and add it outside of the loop where I'm using it a second time.
I have no idea why this is happening and how to proceed.
<?php
// get ACF custom relationship field 'select'
$rmcwordwide = get_field('rights_management_control_by_worldwide', $post->ID); $rmcwordwidearray = str_split($rmcwordwide,2);
$rmcnorthamerica = get_field('rights_management_control_by_northamerica', $post->ID); $rmcnorthamericaarray = str_split($rmcnorthamerica,2);
$rmcusaonly = get_field('rights_management_control_by_usaonly', $post->ID); $rmcusaonlyarray = str_split($rmcusaonly,2);
$rmcusalatam = get_field('rights_management_control_by_usalatam', $post->ID); $rmcusalatamarray = str_split($rmcusalatam,2);
$rmclatamonly = get_field('rights_management_control_by_latamonly', $post->ID); $rmclatamonlyarray = str_split($rmclatamonly,2);
// Merger arrays
$rmcarray = array_merge( (array)$rmcwordwidearray, (array)$rmcnorthamericaarray, (array)$rmcusaonlyarray, (array)$rmcusalatamarray, (array)$rmclatamonlyarray );
// GET USERS COUNTRY LOCATION FROM IP USING MAXMIND
require '/home/xxxx.com/public_html/vendor/autoload.php';
$gi = geoip_open("/home/xxxx.com/public_html/GeoIP.dat",GEOIP_STANDARD);
$ip = strtolower($_SERVER['REMOTE_ADDR']);
$countrycode = strtolower(geoip_country_code_by_addr($gi, $ip));
geoip_close($gi);
if (in_array($countrycode, $rmcarray)): ?>HELLO<?php endif; ?>
So there's one string in each of the arrays. I then break down the string and make a new array for each.
Then I merge the arrays.
Then I get the users location and if an entry in the merged array and the users country code match then...