Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. function my_max(array $values): int {
  2.     $max = $values[0];
  3.     if(is_array($max)) {
  4.         $max = my_max($max);
  5.     }
  6.     foreach ($values as $currentVal) {
  7.         if (is_array($currentVal)) {
  8.             $currentVal = my_max($currentVal);
  9.         }
  10.         if ($max < $currentVal) {
  11.             $max = $currentVal;
  12.         }
  13.     }
  14.     return $max;
  15. }
  16.  
  17. echo my_max( array( array( array(5), 6 ), 3, 4 ) );
  18. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement