Created
January 21, 2011 22:09
-
-
Save bkilshaw/790525 to your computer and use it in GitHub Desktop.
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 // BRAD | |
$numbers = array("1", "2", "3", "4", "5"); | |
function array_print($values) { | |
$array = array_reverse($values); | |
print_values($array); | |
} | |
function print_values($array) { | |
echo array_pop($array); | |
if(empty($array)) { | |
print_values($array); | |
} | |
} | |
array_print($numbers); | |
?> | |
<?php // TJ | |
$numbers = array("1", "2", "3", "4", "5"); | |
a: | |
if (empty($numbers)) exit("Done."); | |
echo array_pop($numbers); | |
goto a; | |
?> | |
<?php // BRAD | |
if($_GET['array']) { | |
$array = unserialize($_GET['array']); | |
} else { | |
$array = array("1", "2", "3", "4", "5"); | |
} | |
if($_GET['string']) { | |
$string = unserialize($_GET['string']); | |
} else { | |
$string = ""; | |
} | |
if($_GET['current']) { | |
$current = $_GET['current']; | |
} else { | |
$current = 0; | |
} | |
if($_GET['stop']) { | |
$stop = $_GET['stop']; | |
} else { | |
$stop = count($array) - 1; | |
} | |
if($current <= $stop) { | |
$string .= "{$array[$current]} "; | |
$current += 1; | |
$array_serialized = serialize($array); | |
$string_serialized = serialize($string); | |
header("Location: {$_SERVER['PHP_SELF']}?array=$array_serialized&string=$string_serialized¤t=$current&stop=$stop"); | |
} else { | |
echo $string; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment