Note "[$t]->value" in the third level nesting of print_r below. What is the proper way to reference [$t] having no numeric or associative label?
print_r ($breedPHP['breeds']['breed'][1]);
var_dump($breedPHP['breeds']['breed'][1]);
produces:
Array ( [$t] => Chinchilla ) //print_r
array(1) { ["$t"]=> string(10) "Chinchilla" } //var_dump
How would I return the value 'Chinchilla' only? aka, how do I reference the constant [$t]?
The querying the API:
$br = new Petfinder('xxxxxxxxxxxxxxxxxxxxxxxxx');
$br->setResponseFormat('json');
$breedJson = $br->breed_list(array('animal'=>'smallfurry'));
$breedPHP = json_decode($breedJson, TRUE);
print_r($breedPHP);
Output of print_r on the parent array:
Array ( [@encoding] => iso-8859-1 [@version] => 1.0 [petfinder] => Array ( [@xmlns:xsi] => http://www.w3.org/2001/XMLSchema-instance [breeds] => Array ( [breed] => Array ( [0] => Array ( [$t] => Abyssinian ) [1] => Array ( [$t] => Chinchilla ) [2] => Array ( [$t]
=> Degu ) [3] => Array ( [$t] => Dwarf Hamster ) [4] => Array ( [$t] => Ferret ) [5] => Array ( [$t] => Gerbil ) [6] => Array ( [$t] => Guinea Pig ) [7] => Array ( [$t] => Hamster ) [8] => Array ( [$t] => Hedgehog ) [9] => Array ( [$t] => Mouse ) [10] => Array ( [$t] => Peruvian ) [11] => Array ( [$t] => Prairie Dog ) [12] => Array ( [$t]
=> Rat ) [13] => Array ( [$t] => Rex ) [14] => Array ( [$t] => Short-Haired ) [15] => Array ( [$t] => Silkie / Sheltie ) [16] => Array ( [$t] => Skunk ) [17] => Array ( [$t] => Sugar Glider ) [18] => Array ( [$t] => Teddy ) ) [@animal] => smallfurry ) [header] => Array ( [timestamp] => Array ( [$t] => 2018-02-22T14:03:34Z ) [status] => Array ( [message] => Array ( ) [code] => Array ( [$t] => 100 ) ) [version] => Array ( [$t] => 0.1 ) ) [@xsi:noNamespaceSchemaLocation]
=> http://api.petfinder.com/schemas/0.9/petfinder.xsd ) )
The same print_r output as above, viewed as html source (for ease):
Array
(
[@encoding] => iso-8859-1
[@version] => 1.0
[petfinder] => Array
(
[@xmlns:xsi] => http://www.w3.org/2001/XMLSchema-instance
[breeds] => Array
(
[breed] => Array
(
[0] => Array
(
[$t] => Abyssinian
)
[1] => Array
(
[$t] => Chinchilla
)
[2] => Array
(
[$t] => Degu
)
[3] => Array
(
[$t] => Dwarf Hamster
)
[4] => Array
(
[$t] => Ferret
)
[5] => Array
(
[$t] => Gerbil
)
[6] => Array
(
[$t] => Guinea Pig
)
[7] => Array
(
[$t] => Hamster
)
[8] => Array
(
[$t] => Hedgehog
)
[9] => Array
(
[$t] => Mouse
)
[10] => Array
(
[$t] => Peruvian
)
[11] => Array
(
[$t] => Prairie Dog
)
[12] => Array
(
[$t] => Rat
)
[13] => Array
(
[$t] => Rex
)
[14] => Array
(
[$t] => Short-Haired
)
[15] => Array
(
[$t] => Silkie / Sheltie
)
[16] => Array
(
[$t] => Skunk
)
[17] => Array
(
[$t] => Sugar Glider
)
[18] => Array
(
[$t] => Teddy
)
)
[@animal] => smallfurry
)
[header] => Array
(
[timestamp] => Array
(
[$t] => 2018-02-22T03:51:30Z
)
[status] => Array
(
[message] => Array
(
)
[code] => Array
(
[$t] => 100
)
)
[version] => Array
(
[$t] => 0.1
)
)
[@xsi:noNamespaceSchemaLocation] => http://api.petfinder.com/schemas/0.9/petfinder.xsd
)
)