Here is the multi dimensional array
$arr = array(
array(141,151,161),
2,
3,
array(
101,
202,
array(303,404)
)
);
How to find the highest value, which the result in the array above should be 404.
The array depth can may be more than 3.
Here is the code i last tried, but i notice this only can check until 3 depth, i need it can be check unlimited depth
function MaxArray($arr){
foreach($arr as $valueDepth1){
if(is_array($valueDepth1)){
foreach($valueDepth1 as $valueDepth2){
if(is_array($valueDepth2)){
foreach($valueDepth2 as $valueDepth3){
$checingArray[]=$valueDepth3;
}
}else{
$checingArray[]=$valueDepth2;
}
}
}else{
$checingArray[]=$valueDepth1;
}
}
return max($checingArray);
}
You can see it in action here: http://codepad.org/4xPFsU1U