Skip to content

Instantly share code, notes, and snippets.

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