//Variables //Garbledness = the size of the order //UserText = the supplied text to travesty //Size = size of the output - will equal the origianl size if not specified. //Offset = Pointer to the current end of the travesty //Outputstring = starts with a string from the start of the text to be travestied the length of the variable Garbledness $Garbledness = htmlspecialchars($_POST['garbledness']); $Usertext = htmlspecialchars($_POST['usertext']); $Size = htmlspecialchars($_POST['size']); $Offset = 0; $Outputstring = substr($Usertext,0,$Garbledness); //Start loop to create the travesty while($Offset < $Size) { //$Searchstring = the phrase we are hunting for in the text to be travestied. $Searchstring = substr($Outputstring, $Offset, ($Offset + $Garbledness)); //Found string will contain a list of letters found after each occurance of $Searchstring $Foundstring = ""; $Pos = 0; while($Pos !== false) { if($Pos > (strlen($Usertext)-1)) $Pos = False; else $Pos=strpos($Usertext,$Searchstring,$Pos); if($Pos !== false) { $Foundstring.=$Usertext[($Pos+$Garbledness)]; $Pos = $Pos+$Garbledness; } } $Outputstring.=$Foundstring[mt_rand(0,strlen($Foundstring)-1)]; $Offset++; } echo '

Travesty N='; echo $Garbledness; echo '


'; echo '
'; echo ''; echo '
'; echo 'Generate a new Travesty'; echo ' or '; echo ' '; echo ' '; echo ' '; echo ' '; echo '
'; ?>
Home - Poetry - Programming