Skip to content

Instantly share code, notes, and snippets.

@kkopachev
Created April 20, 2016 22:40
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 kkopachev/fd8613d052cccf80ba921e0932230521 to your computer and use it in GitHub Desktop.
Save kkopachev/fd8613d052cccf80ba921e0932230521 to your computer and use it in GitHub Desktop.
<?php
$a = range(1,100);
while(count($a) > 1) {
$key = key($a);
unset($a[$key]);
if ( false === current($a) ) {
reset($a);
}
if ( false === next($a) ) {
reset($a);
}
}
echo reset($a), PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment