Build a Buzzword Bingo Card in PHP

By | | Programming

In the past, I’ve done a fair bit of work with government departments. Here are three things I learned from that experience:

  1. government workers love meetings
  2. government workers also love jargon
  3. when you combine meetings and jargon, you have excellent conditions for a quick game of Buzzword Bingo*

If you’ve yet to play Buzzword Bingo, you’re missing out on great fun! It’s a game in which you collect buzzwords, clichés, and weasel words, then arrange them in a grid and check them off as you hear them during a particularly wordy meeting. When you’ve checked off a row, column, or diagonal line — bingo!

With just a little bit of beginner PHP and a good collection of jargon words, you can make your own buzzword bingo card that’s randomly generated every time you load the page. Let’s take a look.

(*Buzzword Bingo has a less than worksafe name too, but because we want this newsletter to pass by unimpeded by any cursing filters, I can’t repeat it here.)

Step 1: Create a Function Shell

We’ll be creating a function called Bingo to generate a random buzzword bingo card, which we can then include within a document. Let’s start out by creating a document shell with the Bingo function inside (I’ve called mine bingo.php):

<?php
  function Bingo() {
  }
?>

Step 2: Compile Some Buzzwords

Grab a list of the jargon words or phrases you’d like to see in your bingo cards. You’ll need at least 25 to fill a bingo card, so be sure you have a good collection. I’ve just spent an amusing few minutes strolling around Weasel Words, a site devoted to collecting some horrible examples of managerial speak, and I’ve plucked a bagful of my favorites.

Let’s pop these in an array inside our PHP function:

$buzzwords = array(
  "leverage",
  "synergy",
  "stakeholder",
  "touch-points",
  "knowledge initiatives",
  "cross-organizational collaboration",
  "strategic planning",
  "dynamics",
  "catalyst",
  "values-driven",
  "evangelize",
  "incentivize",
  "loop back",
  "let's take this offline",
  "360 degree thinking",
  "in the pipeline",
  "actioning",
  "paradigm",
  "2.0",
  "going forward",
  "game plan",
  "the end of the day",
  "thought leading",
  "on board",
  "monetize"
  );

Step 3: Do the Shuffle

We want to make sure our card has a random arrangement of buzzwords, so we’ll use PHP’s shuffle function to jumble up the items in the array:

shuffle($buzzwords);

Step 4: Prepare a Table

Bingo is all about filling up rows or columns in a grid, so we’ll use a table to arrange the items.

Let’s create a new variable called $bingocard and start preparing the table markup. You can see I’ve left a gap in the middle — this is where we’ll later put the code that creates the cells and rows.

$bingocard = "<table id='bingo'
summary='A random selection of 25 buzzwords
arranged in a bingo card'>";
$bingocard .= "<thead><tr>";
$bingocard .= "<th>B</th>
      <th>I</th><th>N</th>
      <th>G</th><th>O</th>";
$bingocard .= "</tr></thead>";
$bingocard .= "<tbody>";
$bingocard .= "<tr>";
// here's the gap
$bingocard .= "</tr>";
$bingocard .= "</tbody>";
$bingocard .= "</table>";

Step 5: Create Cells and Rows

We now need to create 25 cells from the items in our buzzwords array. We’ll use a for loop to iterate through the items in our shuffled array 25 times, and create a table cell for each. That for loop goes in the gap we left in the previous step.

Our table will be a 5×5 grid, so we’ll also need to create five rows, each with five cells. We already prepared the start of our first row and the end of our last row, so we’ll also need to double-check to make sure we don’t do this on the last cell.

To work that out, I’ve used a variable $rowend, which is the remainder of $cell + 1, divided by five. After we create each cell, there’s a small if statement to check whether a $rowend is zero, and that it isn’t the 25th cell. If that’s the case, we’ll close and open a table row element.

Here’s the for loop:

for($cell=0; $cell<25; $cell++)
  {
    $rowend = ($cell + 1) % 5;
    $bingocard .= "<td>"
     . $buzzwords[$cell] . "</td>";
    if($rowend == 0 && $cell < 24) {
      $bingocard .= "</tr>\n<tr>";
    }
  }

Step 6: Echo the Table

We’ve built an array, shuffled it, and made it into a table. All that’s left to do now is print it:

echo $bingocard;

… and we’re nearly done! You should now have a PHP file that looks similar to Example 1.

Step 7: Drop It in A Document

Let’s now use this function in a web page. Include the bingo.php file at the start of the document:

<?php include ('/path/to/bingo.php'); ?>

Now call on the Bingo function wherever you need to put your card:

<?php Bingo(); ?>

Use some CSS to style the buzzword bingo table how you’d like. You can see a very plain example of a bingo card in Example 2, and the results in Example 3. You might even like to layer on some JavaScript to let players check off each cell by clicking on it, or cause an amusing effect when the player achieves bingo.

Step 8: Play!

When you’re happy with how your card looks, it’s time to pass on the URL of the bingo card to your co-workers. Next time there’s a meeting, print a copy for every player, and see who can call bingo first!

Learn Responsive Web Design

Join Learnable $29 Includes all SitePoint books

Raena Jackson Armitage

Raena Jackson Armitage is an Australian web developer with a background in content management, public speaking, and training. When she is not thinking about the Web, she loves knitting, gaming, all-day breakfasts, and cycling.

More Posts - Website - Twitter

{ 27 comments }

Robert K April 28, 2009 at 6:13 pm

Brilliant! Perhaps accumulate a large list and stick it in a database? The you can print off multiple 10′s of sheets for everyone but the presenter to have a go :P

joro6430 April 12, 2009 at 3:09 am

Mmmmm I can answer my own question now. It’s the usual story of pilot error I’m afraid. I messed up the array by omitting a comma on one of the buzz phrases. When that phrase was absent the software was fine, and now works great with lots of buzz phrases. As Dilbert has it, never underestimate the extent of human stupidity.

joro6430 April 11, 2009 at 11:52 pm

Thanks Raena – that worked just fine. Very amusing. However it broke when I added more words to the array. It performs as presented up to 29 words in the array, but crashes with 30 or more words. Can’t see anything wrong with your logic, is it the shuffle() function causing the bug? I cut out your code and substituted
shuffle($buzzwords);

$count=1;
foreach ($buzzwords as $word) {
echo “$count $word, “;
$count++;
}
and this misbehaved similarly – breaking at the array size 30 words barrier. Anybody seen this (mis)behaviour before?

Nathan April 6, 2009 at 11:28 am

Liking the bingo card. I’m learning PHP myself actually and finding it an interesting language. Posting to PHPmule.com/blog. Will be trying to learn more stuff like this in the future!

ghydle March 25, 2009 at 3:50 am

that was fun – more of these fun examples please!!

CamCrow March 8, 2009 at 11:55 am

Our staff did this (at my school) back in the fall; our principal gave us a sheet with a whole bunch of ministry/board terms (some would say BS as is listed above) at the top, and we were to put them in random boxes in a 5×5 grid. I’m our school’s webmaster, if I had this tool I could’ve generated a random sheet for each teacher! ;-)

xxparanormalxx March 7, 2009 at 11:02 pm

greatness.

Lawrence Okpor March 7, 2009 at 8:36 am

To DuleyNoted,
You should save the first example as ‘bingo.php’ and the 2nd example with any name but it should have a .php extension. That should do it. If you have a problem mail me at lawokp@yahoo.com

Courtney March 7, 2009 at 4:03 am

okay, lil challenge (and I’m not a programmer but I understand some logic)

75 words, with 15 available randomly in each column.

I host “indie rock bingo” and simply paste stickers of items randomly on bingo cards, and call them out as randomly as I humanly can, but I’d like to eventually move to a bingo generator with pictures (simple enough right, insert jpgs in the array?) where each icon corresponds to an actual bingo # and I can use my bingo cage.

raena March 5, 2009 at 4:20 pm

@DuleyNoted, My Documents isn’t usually a place where PHP can execute. Try using a regular web server.

Also, for a PHP inclusion to work properly, you need to either tell your web server to make .html files executable by PHP, or change bingo.html to something else with .php at the end. So I’m not sure your bingo.html file will work unless you do one of those things.

If you don’t have a web server, try out XAMPP. It has Apache, PHP, MySQL, lots of other goodies, and runs locally right there on your machine. Free!

Jimmy March 5, 2009 at 4:56 am

This works great unless you’re the one running the meeting. Then you have an incentive for bribery … >:)

RGuinn March 5, 2009 at 1:47 am

Great, I am going to use this tomorrow night at our woodturners meeting/demo. Changed all the buzzwords to woodturning words and give a prize to the first one to get BINGO!

DuleyNoted March 4, 2009 at 9:49 pm

Am I missing something? I used the Example 1 and Example 2 files to create a bingo.html and bingo.php file and placed them both in My Documents. The only thing that renders when I launch the html file is the text “Buzzword Bingo”. I even added the line recommended by ScubaDvr2. Also, I did notice that your Step 7 shows a php include, while your sample file is include once.

Divisive Cotton March 4, 2009 at 8:19 pm

Excellent :)

John March 4, 2009 at 5:00 pm

The point, is that it’s a game as previously explained. And a good one considering.

imaginethis March 4, 2009 at 10:33 am

What’s the point now? I think I missed it some where…

Bob Carologees March 4, 2009 at 9:20 am

can we add “pointless” and “annoying” to the array

raena March 4, 2009 at 9:18 am

You know, it hardly ever occurs to me to think about how it’s done in the US (we don’t do the free cell here in Australia with bingo).

Easily added though, just like that :)

ScubaDvr2 March 4, 2009 at 7:00 am

You forgot one thing.

Right under this:
shuffle($buzzwords);

Add this:
$buzzwords[12] = 'FREE';

Pioneering March 4, 2009 at 6:54 am

@khuramyz I believe you’re thinking of the Chomskybot.

Stressed American March 4, 2009 at 6:16 am

Sounds like government workers need to have a few more layoffs and pay cuts, like those of us that pay their way..

Anonymous March 4, 2009 at 5:54 am

Great tool for increasing meeting participation

ferrari_chris March 4, 2009 at 5:38 am

Personally, I’ve never liked having a function write out HTML for you, as you have when the function has echo and you simply call Bingo();.

I prefer to have the function return an HTML string and then use: echo Bingo();.

But like I said, that’s just a personal thing…

Rexibit March 4, 2009 at 4:16 am

This would be a funny thing to have mixed in with a few of your group’s agenda sheets and see who is the first one to snicker and mouth “BINGO.”

khuramyz March 4, 2009 at 1:38 am

Isnt it the bullshit generator?

raena March 3, 2009 at 11:12 pm

@torkil, I’m not sure how secure my employment would be if I posted BS Bingo all over our home page. ;)

torkil March 3, 2009 at 10:48 pm

I thought this was called Bullshit Bingo? :)

Comments on this entry are closed.