Skip to content

Instantly share code, notes, and snippets.

@christi3k
Created January 13, 2011 03:37
Show Gist options
  • Save christi3k/777344 to your computer and use it in GitHub Desktop.
Save christi3k/777344 to your computer and use it in GitHub Desktop.
<?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