Using the below JSON fragment as an example, if I wanted to access the Value of Year, I would use something like
$result->ItemSpecifics->NameValueList[1]->Value[0] .
However, this only works if you know the index of the Year array element (1 in this case).
My question is, if I don't know what the array index of Year is, how can I still access it' value? Is there a way to find the Year element by name rather than index?
This is not correct but I would expect a solution like:
$result->ItemSpecifics->NameValueList['Year']->Value[0]
JSON Example:
[ItemSpecifics] => stdClass Object
(
[NameValueList] => Array
(
[0] => stdClass Object
(
[Name] => Returns Accepted
[Value] => Array
(
[0] => ReturnsNotAccepted
)
)
[1] => stdClass Object
(
[Name] => Year
[Value] => Array
(
[0] => 2001
)
)
[2] => stdClass Object
(
[Name] => Manufacturer
[Value] => Array
(
[0] => Porsche
)
)