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