You are attempting to get the index value of a string here. To explain:
The following code results in an array:
$rows = get_field(‘location’, ‘option’);
Then you are using the 0 index to get the first value of that array, which will result in yet another array, only this time associative:
$first_row = $rows
Finally, you are able to target the actual field you are looking for by it’s field label, in this case ‘location_phone’:
$first_row_phone = $first_row[‘location_phone’ ];
What results from that line of code is the string value you are looking for. By echoing out
echo $first_row_phone; you are confusing PHP into trying to get the index value of a string. So really, all you need to do is echo the string itself:
Long story short, remove the ‘’ from the echo.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!