SHARE
TWEET

Untitled

a guest Aug 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top