I have a json line:
$fields_string = ' {"fields": {"customers":[{"name":"john","id":"d1"}, {"name":"mike","id":"d2"}, {"name":"andrew","id":"d3"}, {"name":"peter","id":"d4"}] } }'
How can I print each name? I will use them later in html choices, I know how to do this. But I could not pull the string. Here is what I tried:
$obj = json_decode($fields_string); $fields_detail = $obj-?{"fields"}->{"customers"};
at this point I can print the array of clients using echo json_encode($fields_detail) , but before that I want the name to be broken using foreach . I tried several times, this did not work. Can someone help please.
Thanks!
source share