Hi I'm trying to filter my multidimensional array based of the ID passed. I'm almost there but I missed a step somewhere. Here is the code below when I try to filter the array by ID =1 ie: product.php?id=1
Array
(
[Brand] => Array
(
[Type] => Array
(
[0] => Array
(
[ID] => 1
[Name] => Plus
[Size] => XL
[Price] => 100
)
[1] => Array
(
[ID] => 3
[Name] => Shox
[Size] => XL
[Price] => 100
)
[2] => Array
(
[ID] => 2
[Name] => Zoom
[Size] => XL
[Price] => 100
)
[3] => Array
(
[ID] => 1
[Name] => Plus
[Size] => XL
[Price] => 100
)
)
)
)
function array_filter_multi($input, $filter="", $keepMatches=true) {
if (!is_array($input))
return ($input==$filter xor $keepMatches==false) ? $input : false;
while (list ($key,$value) = @each($input)){
$res = array_filter_multi($value, $filter,$keepMatches);
if ($res !== false)
$out[$key] = $res;
}
return $out;
}
$newArray = array_filter_multi($result['Brand']['Type'], $filter= $_GET[id], $keepMatches=true);
print_r($newArray);
Gives me the output of:
Array ( [0] => Array ( [ID] => 1 ) [1] => Array ( [ID] => 1 ) )
It's just giving me the ID's and not the full array with ID, Name, Size, & Price...
Any thoughts? Thx