<?
/*
    09.12.03 - Kyle Christensen <kyle@junglist.org>
    "Jumbler" thing I wrote to pass the time..
*/
?>
<html>
    <body>
<?
    
if (!isset($_POST['body'])) {
?>
    <a href="<?=$_SERVER['PHP_SELF']?>s">view the src</a><br />
    <form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
        <input type="text" name="body" size="50" value="Enter the text you'd like to jumble.">
        <input type="submit" value="Submit">
    </form>
<?
    

    else {
        function 
rm_punct(&$arr) {
            do {
                
$x array_pop($arr);
                
$pos .= $x;
            } while ((
ord($x)<65) && (count($arr)>1));
            return 
$pos;
        }

        function 
jumble($word) {
            for (
$j=0$j<strlen($word); $j++) {
                
$arr[] = substr($word,$j,1);
            }

            
$last strrev(rm_punct($arr));
            
$arr array_reverse($arr);
            
$first rm_punct($arr);
            
shuffle($arr);

            foreach (
$arr as $x) { $mid .= $x; }
            return 
$first $mid $last " ";
        }
        
$body=split(" ",$_POST['body']);
        foreach (
$body as $x) { print jumble($x); }
    }
?>
    </body>
</html>