无法访问PHP数组的成员[关闭]

enter image description here

This JSON I have converted to an array in PHP. when i get the sizeof or count, the array size is 1 Do you not get an associative array using json_decode in PHP? after the JSON below you see i echo out the typeof, so you see it is array, then size of, and you see it is 1 Any idea why I cant access the value for 'name' in the resulting array and why it is of size 1?

The reason count is returning 1 is because your JSON is structured in such a way that it represents an array of objects, of which you only have 1 (note the single set of braces). If you would like to count all elements within the first and only object in your JSON array, you could instead try:

count($json[0]);

Well, look at the JSON. It's an array of an object.

echo $json_decoded[0]->name; // chemist

var_dump may be useful next time.