I am accessing product details through Amazon API and get this in my array of data:
["BrowseNodes"]=>
array(1) {
["BrowseNode"]=>
array(3) {
[0]=>
array(3) {
["BrowseNodeId"]=>
string(10) "7421468011"
["Name"]=>
string(24) "Educational & Nonfiction"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(3) {
["BrowseNodeId"]=>
string(4) "4390"
["Name"]=>
string(14) "Graphic Novels"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(3) {
["BrowseNodeId"]=>
string(4) "4366"
["Name"]=>
string(23) "Comics & Graphic Novels"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(4) {
["BrowseNodeId"]=>
string(4) "1000"
["Name"]=>
string(8) "Subjects"
["IsCategoryRoot"]=>
bool(true)
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(2) {
["BrowseNodeId"]=>
string(6) "283155"
["Name"]=>
string(5) "Books"
}
}
}
}
}
}
}
}
}
[1]=>
array(3) {
["BrowseNodeId"]=>
string(5) "13871"
["Name"]=>
string(20) "History & Philosophy"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(3) {
["BrowseNodeId"]=>
string(2) "75"
["Name"]=>
string(14) "Science & Math"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(4) {
["BrowseNodeId"]=>
string(4) "1000"
["Name"]=>
string(8) "Subjects"
["IsCategoryRoot"]=>
bool(true)
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(2) {
["BrowseNodeId"]=>
string(6) "283155"
["Name"]=>
string(5) "Books"
}
}
}
}
}
}
}
[2]=>
array(3) {
["BrowseNodeId"]=>
string(5) "11256"
["Name"]=>
string(20) "Folklore & Mythology"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(3) {
["BrowseNodeId"]=>
string(5) "11232"
["Name"]=>
string(15) "Social Sciences"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(3) {
["BrowseNodeId"]=>
string(10) "3377866011"
["Name"]=>
string(26) "Politics & Social Sciences"
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(4) {
["BrowseNodeId"]=>
string(4) "1000"
["Name"]=>
string(8) "Subjects"
["IsCategoryRoot"]=>
bool(true)
["Ancestors"]=>
array(1) {
["BrowseNode"]=>
array(2) {
["BrowseNodeId"]=>
string(6) "283155"
["Name"]=>
string(5) "Books"
}
}
}
}
}
}
}
}
}
</pre>
The point is I need to extract Value "Politics & Social Sciences" in this example and depth is not always the same. However every array starts the same from the end - Books -> Subjects -> Politics & Social Sciences
Since I am running hundreds of books through my script I need automated way of getting the 3rd level from the bottom. It is always 3rd level from the end of array.