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