Here's a random story'; $nouns = array('dog','cat','hand','arm','head','foot','leg','bones','chest','eyes','hair','nose','ears','finger','table','chair','fridge','shoe','coat','dress','skirt','pair of trousers','pair of socks','cardigan','blouse','shirt','tie','boat','car','bike','television','radio','computer','telephone','hat','umbrella','necklace','scooter','camera','piano','banjo','guitar','flute','tuba','garden','house','shed','greenhouse','diary','ferret','horse','baby','hammer','pen','pencil','watch','clock','bucket','box of tissues','money','comb','mirror','cupboard','Playboy collection','newspaper','saw','knife','handgun','rifle','machine gun','sword','lawnmower','ladder','cooker','telescope','binoculars','sunglasses','van','lorry','yo-yo'); $nounstotal = count($nouns) - 1; $ok = 'no'; while($ok == 'no') { $noun = rand(0,$nounstotal); $noun2 = rand(0,$nounstotal); if ($noun <> $noun2) {$ok = '';} } $verbs = array('use','wiggle','open','take off','take off on','fall off','sit on','stand on','undo','throw','lay down','pick','pick up','look at','clean','touch','stroke','lick','feel','steal','grab','poke','hit','buy','eat','roast','boil','point','tear up','open','wash','destroy','drown','torture','burn','lift','lift up','pull','pull down','jump on','jump off','love','dance with','rearrange','paint over','colour in','crush','beat up','smash','pull apart','polish','kiss'); $verbstotal = count($verbs) - 1; $ok = 'no'; while($ok == 'no') { $verb = rand(0,$verbstotal); $verb2 = rand(0,$verbstotal); if ($verb <> $verb2) {$ok = '';} } $adverbs = array('gently','violently','carefully','lovingly','angrily','suddenly','confidently','nervously','unexpectedly','forcefully','rapidly','gradually','slowly','quickly','repeatedly','softly','eventually'); $adverbstotal = count($adverbs) - 1; $ok = 'no'; while($ok == 'no') { $adverb = rand(0,$adverbstotal); $adverb2 = rand(0,$adverbstotal); if ($adverb <> $adverb2) {$ok = '';} } $actions = array('run off with','marry','kill','find','kiss','caress','look for','attack','dance with','go skating with','travel abroad with','go golfing with','smother','chase','smile at','intimidate','irritate','confuse','seduce','flirt with','puzzle'); $actionstotal = count($actions) - 1; $ok = 'no'; while($ok == 'no') { $action = rand(0,$actionstotal); $action2 = rand(0,$actionstotal); if ($action <> $action2) {$ok = '';} } //split into male, female and either(any) $persons = array( 'brother', 'father', 'son', 'grandfather', 'nephew', 'uncle', 'sister', 'mother', 'daughter', 'grandmother', 'niece', 'aunt', 'postman', 'courier', 'baker', 'butcher', 'farmer', 'sailor', 'banker', 'teacher', 'childminder', 'babysitter', 'shop assistant', 'van driver', 'lorry driver', 'biker', 'mayor', 'photographer', 'programmer', 'designer', 'chef', 'cleaner', 'carpenter', 'builder', 'lawyer' ); $personstotal = count($persons) - 1; $ok = 'no'; while($ok == 'no') { $person = rand(0,$personstotal); $person2 = rand(0,$personstotal); $person3 = rand(0,$personstotal); if (($person <> $person2) and ($person <> $person3) and ($person2 <> $person3)) {$ok = '';} } if ($person < 6) { $prefixperson1 = 'my'; $prefixperson1b = 'He'; $prefixperson1c = 'his'; $prefixperson1d = 'he'; } if (($person > 5) and ($person < 12)) { $prefixperson1 = 'my'; $prefixperson1b = 'She'; $prefixperson1c = 'her'; $prefixperson1d = 'she'; } if ($person > 11) { $prefixperson1 = 'a'; $prefixperson1b = 'The '.$persons[$person]; $prefixperson1c = 'their'; $prefixperson1d = 'they'; } if ($person2 < 6) { $prefixperson2 = 'my'; $prefixperson2b = 'him'; } if (($person2 > 5) and ($person2 < 12)) { $prefixperson2 = 'my'; $prefixperson2b = 'her'; } if ($person2 > 11) { $prefixperson2 = 'a'; $prefixperson2b = 'them'; } if ($person3 < 12) { $prefixperson3 = 'my'; } else { $prefixperson3 = 'a'; } $bodybackground = '#fff'; $headerbackground = '#d9d9d9'; $holderbackground = '#e3e3e3'; $mainbackground = '#eee'; $footerbackground = '#d3d3d3'; $headertext = $maintext = $sidebartext = $footertext = '#333'; echo << html {border:0;} /* removes window edge in IE6! */ * {font-family:'Trebuchet MS',Arial,Helvetica,sans serif;} html, body { margin:0; padding:0; background-color:#fff; color:#000; } body { font-size:14px; z-index:0; line-height:19px; padding:30px; width:900px; } h1 {font-size:21px;} h2 {font-size:19px;} h3 {font-size:17px;} h4 {font-size:15px;} h5, h6 {font-size:14px;} input, textarea { font-family:'Courier New',Courier,monospace; font-size:0.9em; } input {width:2.5em;} ins, code ins {text-decoration:none;} code, code *, var { font-family:'Courier New',Courier,monospace; } var {font-style:normal;} dt, dd {display:inline;} dt {font-weight:bold;} dd {font-weight:normal; margin-left:0;} small {font-size:0.89em;} abbr {cursor:help;} /* - - - IDS - - - */ #holder { width:900px; } /* setting fixed width stops sidebar dropping down if screen narrow */ #main { float:left; height:auto; width:570px; } #sidebar { float:left; width:240px; /* should be more but IE can drop the column */ } #header, #main, #sidebar, #footer { padding:10px 20px 10px 20px; } #footer { clear:both; width:860px; } #footer h3.first {padding-top:0;} #footer h3 {padding-top:20px;} /* #footer, #lastupdated {font-size:87%;} */ /* - - - CLASSES - - - */ /* indents for code */ .s1 {padding-left:2em;} .s2 {padding-left:4em;} .s3 {padding-left:6em;} .s4 {padding-left:8em;} .s5 {padding-left:10em;} .clear {clear:both;} .center {text-align:center;} .left {text-align:left;} .indent {margin-left:30px;} .comment { font-weight:normal; font-style:italic; } html, body {background-color:$bodybackground;} #holder { background-color:$holderbackground; border:1px solid $headertext; } #header { color:$headertext; background-color:$headerbackground; border-bottom:1px solid $headertext; } #main { color:$maintext; background-color:$mainbackground; border-right:1px solid $headertext; } #sidebar { color:$sidebartext; background-color:transparent; /* holder background colour used to get max height */ } #footer { color:$footertext; background-color:$footerbackground; border-top:1px solid $headertext; } :link, :visited {text-decoration:none;} #header :link { border:1px solid $headertext; color:$headertext; } #header :visited { border:1px dotted $headertext; color:$headertext; } #header :link:hover, #header :visited:hover { color:$headerbackground; background-color:$headertext; } #main :link { border:1px solid $maintext; color:$maintext; } #main :visited { border:1px dotted $maintext; color:$maintext; } #main :link:hover, #main :visited:hover { color:$mainbackground; background-color:$maintext; } #sidebar :link { border:1px solid $sidebartext; color:$sidebartext; } #sidebar :visited { border:1px dotted $sidebartext; color:$sidebartext; } #sidebar :link:hover, #sidebar :visited:hover { color:$holderbackground; background-color:$sidebartext; } #footer :link { border:1px solid $footertext; color:$footertext; } #footer :visited { border:1px dotted $footertext; color:$footertext; } #footer :link:hover, #footer :visited:hover { color:$footerbackground; background-color:$footertext; } input, textarea {color:#000;} blockquote { padding:10px 20px 10px 20px; margin:40px 8px 40px 8px; font-style:italic; border:3px double $maintext; } $title

Introduction

Below is a short story created randomly from a predefined set of words. Every time you refresh the page, the story changes. I find some of the results hilarious. I hope you do too.

One day $prefixperson1 {$persons[$person]} decided to {$actions[$action]} $prefixperson2 {$persons[$person2]}. $prefixperson1b would {$adverbs[$adverb]} {$verbs[$verb]} $prefixperson1c {$nouns[$noun]} to {$actions[$action2]} $prefixperson2b. And if that didn't work, $prefixperson1d would {$adverbs[$adverb2]} {$verbs[$verb2]} $prefixperson3 {$persons[$person3]}'s {$nouns[$noun2]}.

You can view the code used to generate the page if you like.

HTML; ?>