Random Demo No.2

4 April 2006 · Last updated: 11 December 2006

Comments


This is my second demo using randomness to generate part of a web page. Before it was random background colours. This time it's random words. A short story is compiled from various words that change when you refresh the page. The story isn't meant to be serious, or have any meaning. In fact it's quite comical! I had to stop working at it in the end, as I was making myself laugh so much at the funny lines that were coming up randomly!

PHP is used to build the story by first putting groups of useful words into arrays. These include types of people, verbs, adverbs, actions and so on. In the end it got quite complex, despite the simplicity of the text you see output on screen. That's because I added extra code to do things like checking that two verbs in the story weren't the same ones chosen at random. I also spent a long time getting various words right to match the genders of the people chosen for the story. In other words (sigh), it wasn't as easy as it looks.

I could probably have added a lot more words to the arrays I used, but I wanted to release the demo now, rather than later. It's only meant to be a rough guide to what you can do with randomness anyway, not a perfected program. Even so, it might give you an idea for something more practical that you might use on your website. Or just use it when you're feeling down, and need a laugh!

The Demo

Random Story Demo

Related Links

Random Demo No.1

Random Demo No.3


Comments (2)

Comments are locked on this topic. Thanks to everyone who posted a comment.

  1. Karlyn:
    I like this, how creative and fun! :-)

    Posted on 7 April 2006 at 6:55 pm
  2. Dafin:
    haha! quite funny :-D

    Posted on 17 May 2006 at 2:58 pm

Useful Info

EMAIL: www.designdetector.com (replace the 1st dot with "@")

NEWSFEED: Subscribe to news of fresh posts and site updates. (RSS 2.0 compatible newsreader required.)

Disclaimer

Some links on this website lead to information provided by external services not under my control, therefore I am not responsible for the content or accuracy of the linked information.

All code examples are not guaranteed 100% free from bugs and/or mistakes. Use them at your own risk. I do not take any blame should a problem occur relating to use of code on this site given as an example for your own use. Such code has been tested and found to work for me, but I cannot vouch for other computer systems (existing now, or in the future) which it may be used on, or changes you introduce yourself based on my code.

This website is © 2008 Christopher Hester, except where separate authors are named. No part of this website may be reproduced or re-used in any way without my prior permission, except content added from separate authors (who retain the copyright on their material), examples of code, and any other content I explicity state is free to copy and make use of.

This page was last updated on 11 December 2006.

What's New

Recent Finds


View previous finds


Current Reading

The Suspicions Of Mr Whicher (Or The Murder At Road Hill House) by Kate Summerscale
5%
Genesis: Chapter & Verse by Tony Banks, Phil Collins, Peter Gabriel, Steve Hackett & Mike Rutherford
70%
Digital Photographer's Handbook by Tom Ang
70%