I have a problem that I have to make 10 loops depends on arrays number in order to get the data.
I fixed that by some help from my other post, but I have one issue renaming
The array I'm using
Array
(
[catalog] => Array
(
[book] => Array
(
[0] => Array
(
[took] => Array
(
[dodo] => Array
(
[ahmadz] => Array
(
[lolo] => Array
(
[tata] => Array
(
[author] => ahmadz
[title] => Midnight Rain
[genre] => Fantasy
[price] => 5.95
[publish_date] => 2000-12-16
[description] => A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.
)
)
)
)
)
)
[1] => Array
(
[took] => Array
(
[dodo] => Array
(
[ahmadz] => Array
(
[lolo] => Array
(
[tata2] => Array
(
[author] => Ralls, Kim
[title] => Midnight Rain
[genre] => Fantasy
[price] => 5.95
[publish_date] => 2000-12-16
[description] => A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.
)
)
)
)
)
)
)
)
)
And this how I get a specific data from it
$author_array = array();
array_walk_recursive($array, function($value, $key) {
if (in_array($key, array("author"))) {
echo $author_array[] = $value;
}
});
The problem I have that before these values
[author] => ahmadz
[title] => Midnight Rain
[genre] => Fantasy
[price] => 5.95
I have different keys
tata and tata2
I want to get only the values in "tata" key
but the code above is returning both values from "tata" and "tata2" keys
Please help me to get the data from one key not both