$pf = new Petfinder('API_KEY');
$pf->setResponseFormat('json');
$petJson = $pf->pet_find(array('output'=>'basic', 'location' => '32810', 'count' => '25'));
$pet = json_decode($petJson);
foreach ($pet as $pets)
{
print_r($pets);
}
我试过var_dump($pets->pets->pet);
了,但没有用。
/* 回复 */
iso-8859-11.0stdClass Object
(
[lastOffset] => stdClass Object
(
[$t] => 1
)
[pets] => stdClass Object
(
[pet] => stdClass Object
(
[options] => stdClass Object
(
[option] => stdClass Object
(
[$t] => housebroken
)
)
[breeds] => stdClass Object
(
[breed] => stdClass Object
(
[$t] => Domestic Short Hair
)
)
[shelterPetId] => stdClass Object()
[status] => stdClass Object
(
[$t] => A
)
[name] => stdClass Object
(
[$t] => Bottle Fed Kittens
)
[contact] => stdClass Object
(
[email] => stdClass Object
(
[$t] => catboutcolonies@yahoo.com
)
[zip] => stdClass Object
(
[$t] => 32810
)
[city] => stdClass Object
(
[$t] => Orlando
)
[fax] => stdClass Object()
[name] => stdClass Object
(
[$t] => Lori Lewis
)
[address1] => stdClass Object
(
[$t] => P.O.Box 607082
)
[phone] => stdClass Object
(
[$t] => 407-953-0297
)
)
[description] => stdClass Object
(
[$t] =>
)
[sex] => stdClass Object
(
[$t] => F
)
[media] => stdClass Object
(
[photos] => stdClass Object
(
[photo] => Array
(
[0] => stdClass Object
(
[@size] => x
[$t] => http://photos.petfinder.com/photos/US/FL/FL1155/26769037/FL1155.26769037-1-x.jpg
[@id] => 1
)
[2] => stdClass Object
(
[@size] => t
[$t] => http://photos.petfinder.com/photos/US/FL/FL1155/26769037/FL1155.26769037-3-t.jpg
[@id] => 3
)
)
)
)
[id] => stdClass Object
(
[$t] => 26769037
)
[animal] => stdClass Object
(
[$t] => Cat
)
)
)
[header] => stdClass Object
(
[timestamp] => stdClass Object
(
[$t] => 2013-08-13T05:54:46Z
)
[status] => stdClass Object
(
[message] => stdClass Object()
[code] => stdClass Object
(
[$t] => 100
)
)
[version] => stdClass Object
(
[$t] => 0.1
)
)
[@xsi: noNamespaceSchemaLocation] = > http: //api.petfinder.com/schemas/0.9/petfinder.xsd
)
我只是想提取一个元素,例如品种,任何帮助将不胜感激。