Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_max($array)
- {
- foreach($array as $key => $value) {
- if (is_array($value)) {
- $array[$key] = my_max($value);
- }
- }
- $maxNumber = $array[0];
- for($j = 0; $j < count($array); $j++){
- if($maxNumber < $array[$j]){
- $maxNumber = $array[$j];
- }
- }
- return $maxNumber;
- }
- echo my_max([1, 2, [3, [1000, 4, 5], 6, 7], 8, 9])
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement