Random Demo No.2

4th April 2006 · Last updated: 5th October 2016
 

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