我搜索了很多,我找到了一些方法来查找我的
JSON数组的长度.我试过了:
>数
> json.length
但这些返回1,而不是实际长度.我想用PHP来展示它.
我的json是:
$huge = '[{"location":[{"building":["Default Building"],"name":"Default Location"}],"name":"Default Organization"},{"location":[{"building":["test_loc1_building1","test_loc1_building2"],"name":"test location1"},{"building":["test_loc2_building2"],"name":"test location2"}],"name":"test Organization"}]';
如何在JSON数组中找到对象的数量?
你需要
decode the json对象,然后计算其中的元素..
原文链接:https://www.f2er.com/php/136800.html$json_array = json_decode($json_string,true); $elementCount = count($json_array);