I cURL to a page which produces an array of json of the fashion:
[{"id":1,"name":"Drew"},{"id":2,"name":"Joyce"},{"id":3,"name":"Vick"}]
I use $result = json_decode($json, true)
to get back an associative array.
I am having trouble though iterating through the array though and accessing individual pieces of each json object like the name field. Is there an easy way to accomplish this?
Another issue is, I was planning to use a foreach
loop as I might not know the exact length of the array of json objects, is there a way to incorporate the solution to my first issue into a for each loop or other structure that might take in a variable sized array and stop when it reaches the end?