function maxNum($array) { if (count($array) == 1) { return $array[0]; } $num = array_shift($array); $maxNum = maxNum($array); return $num > $maxNum ? $num : $maxNum;}$a = [1,4,6,3,8];$res = maxNum($a);var_dump($a);