Here is print_r output of my array:
Array
(
[0] => stdClass Object
(
[itemId] => 560639000019
[name] => Item no1
[code] =>
foreach($parentObj AS $key=>$element){
if ($element->id == THE_ID_YOU_ARE_LOOKING_FOR){
echo "Gottcha! The index is - ". $key;
}
}
$parentObj
is obviously your root array - the one that holds all the others.
We use the foreach
loop to iterate over each item and then test it's id
property against what ever value you desire. Once we have that - the $key
that we are on is the index you are looking for.