SHARE
TWEET

Untitled

a guest Apr 18th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function my_max($xs)
  4. {
  5.     $max = null;
  6.  
  7.     foreach ($xs as $x) {
  8.         if (is_array($x)) {
  9.             $x = my_max($x);
  10.         }
  11.  
  12.         if ($x > $max) {
  13.             $max = $x;
  14.         }
  15.     }
  16.  
  17.     return $max;
  18. }
  19.  
  20. echo my_max([1, [2, 3]]);
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