Skip to content

Instantly share code, notes, and snippets.

@yumemi-kuwahara
Created April 19, 2018 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumemi-kuwahara/3d5891229dbecf3e7354c474bfb0b3db to your computer and use it in GitHub Desktop.
Save yumemi-kuwahara/3d5891229dbecf3e7354c474bfb0b3db to your computer and use it in GitHub Desktop.
#YYPHP で出されたクイズの回答
<?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