I am getting an array of data from a wordpress custom field with this code:
<?php
$values = get_field('google_location');
if($value) {
foreach($values as $value) {
echo $value;
}
}
?>
and here is the output from the array:
array(2) { ["coordinates"]=> string(22) "38.9974266,-77.1104762" ["address"]=> string(48) "8600 Old Georgetown Rd, Bethesda, Maryland 20814" }
array(2) { ["coordinates"]=> string(29) "37.7911347,-79.88268779999999" ["address"]=> string(26) "Arh Ln, Low Moor, VA 24457" }
array(2) { ["coordinates"]=> string(21) "38.9010559,-77.050792" ["address"]=> string(36) "900 23rd St NW, Washington, DC 20037" }
how do I grab the coordinates (long, lat) in these arrays from the string and insert them into li items. I want my HTML to look like this:
<ul>
<li>38.9974266,-77.1104762</li>
<li>37.7911347,-79.88268779999999</li>
<li>38.9010559,-77.050792</li>
</ul>
So $value is pretty much all the data you’re getting. Because you just want to coordinates you’ll have something like this:
This should work. I didn’t check it, but it should work