Created
January 13, 2011 00:57
-
-
Save christi3k/777208 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 | |
/** | |
* strrev.php Takes a string as a command line argument and reverses it. | |
* | |
* @author Christie Koehler <christiekoehler@gmail.com> | |
*/ | |
if($argc > 1 && $argv[1] != '--help'){ | |
if($argv[1] == '--harder') | |
echo (implode(array_reverse(str_split($argv[2])))); | |
else | |
echo strrev($argv[1]); | |
} | |
else { | |
echo "Type in a string in quotes (single or double).\n"; | |
echo " ex: strrev.php 'fear is the mind killer'\n"; | |
echo " use --harder if you want to do it the hard way"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment