Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function my_max(array $values): int {
- $max = $values[0];
- foreach ($values as $currentVal) {
- if (is_array($currentVal)) {
- $currentVal = my_max($currentVal);
- }
- if ($max < $currentVal) {
- $max = $currentVal;
- }
- }
- return $max;
- }
- echo my_max([1, 2, 3, [5, 7]]);
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement