嗨,我正在尝试遍历一个 json 对象数组,但实际上我什么也没得到,这是我的尝试。
$jsonurl = 'http://eol.org/api/search/1.0.json?q='."$searchvar".'&page=1&exact=false& filter_by_taxon_concept_id=&filter_by_hierarchy_entry_id=&filter_by_string=&cache_ttl=';
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
foreach ($json_output->dataObjects as $objects){
print "{$objects->title}\n";
}
这是实际 json 数组的结构。
array
0 object
id 19076
title Vulpes
link http://eol.org/19076?action=overview&controller=taxa
content Arctic foxes; kit foxes; red foxes; red fox