<?php
$filename 
"data.txt";
$bingo_size "5x5";
$middle 2;
// ...

$text file_get_contents($filename);
$words preg_split("/\n/"$text);
//var_dump($words);
$count count($words);
//echo $count;
list($size_x$size_y) = explode("x"$bingo_size);

if (
$count < ($size_x $size_y)) {
  die(
"not enough words to create $size_x by $size_y grid.\n");
}
$put_keys = array();
?>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Buzzword bingo !</title>
  <style type="text/css">
  table {
    
  }
  table tr td {
    border:4px #999 groove;
    padding:6px;
    text-align:center;
  }
  body {
    background-color:#eee;
    padding:0; margin:0;
    text-align:left;
  }
  #header {
    background-color:#69c;
    display:block;
    width:100%;
    padding:6px;
    color:#fff;
    text-align:center;
  }
  #footer, #footer a {
    font-size:9px;
    color:#666;
    text-align:center;
    text-decoration:none;
  }
  #container {
    text-align:center;
    margin:30px;
  }
  a {
    color:#fff;
  }
  </style>
</head>
<body>
<div id="header">
  <h1>Buzzword bingo</h1>
  <a href="index.php">Generate again</a> | <a href="source.php">View source</a>
</div>
<div id="container">
<?php
echo "<table align=\"center\">";
for (
$i 0$i $size_x$i++) {
  echo 
"\t<tr>\n";
  for (
$j 0$j $size_x$j++) {
    if (
$i == $middle && $j == $middle) {
      echo 
"\t\t<td style=\"background-color:#ccc;\">BINGO</td>\n";
    } else {
      
$rand rand(0$count 1);
      
//echo $rand;
      
while (array_search($rand$put_keys) !== FALSE) {
        
$rand rand(0$count 1);
      }
      
$put_keys[] = $rand;
      echo 
"\t\t<td> ";
      echo 
$words[$rand];
      echo 
"</td>\n";
    }
  }
  echo 
"</tr>";
}
echo 
"</table>";
?>
</div>
<br /> <br /> <br /> <br />
<div id="footer">Copyleft 2006 <a href="http://alexandre.quessy.net/">Alexandre Quessy</a></div>
</body>
</html>