Bogan Ipsum – How to guide

bogan-ipsum-feature

A couple of days ago whilst working at Eleven Media the boys were discussing the latest Lorem Ipsum generator they had discovered, “Hipster Ipsum“. Anyway there was some discussion about creating a more “Aussie” Ipsum generator. For those of you unaware, Lorem Ipsum is basically some old Latin text that is used as dummy or filler copy during early design phase of print and web design work.

The Plan

So we started to think about how to construct our own generator with more colloquial “bogan” words. Aaron had found a nice list of words off some urban dictionary type site and we discussed the basics of how sentences might be generated. It had to be random, make no sense, but still follow the structure of a sentence. So we developed the following ‘sentence format':

Phrase + Word + connecting word/phrase + Phrase 2 + Word 2.

So for instance, a phrase might be “She looks like a…” and then a word is your slang, for instance “mongrel”, and a connecting phrase or word might be “on a”. Which would give us “She looks like a mongrel on a…”

The Bogan Words

With this ironed out it was a matter of getting the 330 words, 25 phrases, and a handful of connecting phrases into a database. We used 3 separate tables for each of these. you can download these here:

Bogan Words Table

Bogan Phrases Table

Filler/Connecting Phrases Table

You could realistically create your own table of words for any other type of colloquialism or slang to substitute in.

The Ipsum Generator

Ok, next step is now to connect to your database and create some variables / arrays to hold the words and phrases. Realistically you could just program in the words right into a PHP Array and not bother with a database altogether, in which case populate the array vars below with your words.

1
2
3
4
5
6
7
//vars
$words = array(); //to hold our DB data or to store words in directly
$phrases = array(); //regular phrases
$fillers = array(); //connecting phrases
$paras = 4; //Number of paragraphs to generate
$sentence_max = 9; //Max number of sentences in a paragraph
$sentence_min = 5; //Min number of sentences in a paragraph

Again, we used a database and 3 tables to store everything so below are the queries used to pass data to our arrays, you could just store the data in the arrays to begin with

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//select words
$sql = "SELECT word FROM bogan_words";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$words[] = $row['word'];
}
mysql_free_result($result);

//select phrases
$sql = "SELECT phrase FROM bogan_phrases";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$phrases[] = $row['phrase'];
}
mysql_free_result($result);

//select fillers
$sql = "SELECT filler FROM bogan_fillers";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$fillers[] = $row['filler'];
}
mysql_free_result($result);

Now the fun part – generating sentences and paragraphs using random items from each array we have just populated. The logic here is pretty simple and relies on some nested for loops.

The outer loop controls paragraph generation, the inner loop controls sentence generation. I used rand() with the max and min values set earlier to randomise the number of sentences per paragraph so it always creates a different Ipsum text.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//generate paras
for($i=1;$i //generate sentences
    $sentence_per_para = rand($sentence_min,$sentence_max);
    echo '<p>';
    for($j=1;$j //generate words
        $word1 = strtolower(rtrim($words[rand(1,sizeof($words))]));
        $word2 = strtolower(rtrim($words[rand(1,sizeof($words))]));
        $phrase1 = rtrim($phrases[rand(1,sizeof($phrases))]);
        $phrase2 = strtolower(rtrim($phrases[rand(1,sizeof($phrases))]));
        $filler1 = rtrim($fillers[rand(1,sizeof($fillers))]);
        $sentence = $phrase1.' '.$word1.' '.$filler1.' '.$phrase2.' '.$word2.'. ';
        echo $sentence;
    }
    echo '</p>';
}

And that is that. Yes it could probably be a little neater or more streamlined here and there, but this was smashed out on a late afternoon as a bit of fun and not anything serious. You could use this code to create any sort of Lorem Ipsum Generator or even random sentences so hopefuly it is helpful to someone out there.

Download

Click here to download the full source for Bogan Ipsum (PHP + MySQL tables) and create your own Ipsum generator today!

Of-course this was a team effort so props to @AaronRutley for UI and frontend dev, @BlazRobar for Design and @xavierverhoeven for the concept.

You can checkout the finished product here – www.boganipsum.com

  • Blaz

    Nice work as usual mate!

    • http://www.thehonch.net Mateusz Michalik

      Nice comment as usual mate!

    • http://www.thehonch.net Mateusz Michalik

      Nice comment as usual mate!