Created
April 19, 2018 02:58
-
-
Save yumemi-kuwahara/3d5891229dbecf3e7354c474bfb0b3db to your computer and use it in GitHub Desktop.
#YYPHP で出されたクイズの回答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = [1, [2, [3, [4, [5]]]]]; | |
$b = [1, 2, 3, 4, 5]; | |
function f($a) { | |
global $ret; | |
foreach ($a as $val) { | |
if (!is_array($val)) { | |
$ret[] = $val; | |
} else { | |
f($val); | |
} | |
} | |
return $ret; | |
} | |
$c = f($a); | |
if ($b === $c) { | |
echo "OK"; | |
} else { | |
echo "NG"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment