我想用recursive
功能我互聯網上找到找到一個array
max
找到陣列最大爲使用遞歸函數
function multimax($id)
{
$max = $id[0];
foreach($id as $value)
{
if($value > $max)
{
$max = $value;
}
else if(is_array($value))
{
$subvalue = multimax($value);
if($subvalue > $max)
{
$max = $subvalue;
}
}
}
return $max;
其中$id
是陣列和$max
是最大值。
它工作正常,但我不知道如何。任何人都可以請幫助理解數據流
逐行調試代碼。 – 2014-10-29 12:11:40