This is my array:
array(1) {
["farm"]=>
array(1) {
["animals"]=>
array(1) {
[horses]=>
array(4) {
["fred"]=>
string(4) "fred"
["sam"]=>
string(4) "sam"
["alan"]=>
string(4) "alan"
["john"]=>
string(4) "john"
}
}
}
}
And this is my URL
mypage.php?id=2&dir=animals
I would like to print the children of my URL parameter dir
(In this case:animals)
This is the way I try to do it:
foreach($array as $sub) {
if ($_GET['dir'] == $sub){
$result = array_merge($result, $sub);
echo $result;
}
}
My result: An empty page.
The result I wish: horses