Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_max($xs)
- {
- $max = null;
- foreach ($xs as $x) {
- if (is_array($x)) {
- $x = my_max($x);
- }
- if ($x > $max) {
- $max = $x;
- }
- }
- return $max;
- }
- echo my_max([1, [2, 3]]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement