Advertisement
Guest User

Untitled

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