Aug 20 2010

Code Poetry Redeux, Ryans Response

Posted by: Jason Ferguson

As usual, ryan wins this round.

<?php
//jackandjill.php
$kidsnames = $_SERVER['PHP_SELF'];
$kidsnames = basename($kidsnames, ".php");
$firstkid = substr($kidsnames,0,4);
$joinword = substr($kidsnames,4,3);
$secondkid = substr($kidsnames,7,4);
$kidsnames = $firstkid . " " . $joinword . " " . $secondkid;
function makewherecode($whereto){
if($whereto == "halibel"){
$newplace = substr($whereto,0,1);
$newplace = $newplace . substr($whereto,3,1);
$newplace = $newplace . substr($whereto,2,1);
$newplace = $newplace . substr($whereto,2,1);
return $newplace . "\n";
}
}
function hextostr($hex)
{
    $string='';
    for ($i=0; $i < strlen($hex)-1; $i+=2)
    {
        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
    }
    return $string;
}
$rhyme =  nl2br($kidsnames . " went &uarr; a " . makewherecode("halibel"));
$getting = array("pail","water");
$line = "to fetch a " . $getting[0] . " of " . $getting[1];
$rhyme = $rhyme . $line . "<br>";
$line = $firstkid . " fell &darr; <br>";
$rhyme = $rhyme . $line;
$brokewhat = "63726f776e";
if (hextostr($brokewhat) == "crown"){
$line = $joinword . " broke his " . hextostr($brokewhat);
}
$rhyme = $rhyme . $line . hextostr("3c62723e");
$line = $joinword . " " . $secondkid . " came tumbling after.";
$rhyme = $rhyme . $line;
echo $rhyme;
?>