Build a Buzzword Bingo Card in PHP

    Share

    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!