Boggle Game Generator

Boggle game generator! A simple PHP script that creates a 5x5 Boggle board game layout. The PHP script creates random letters -- print them out and you and your friends or co-workers can play for hours!
show me!

A friend of mine mentioned Boggle one day and I had an unusual desire arise that I could easily create a web page that generated a random Boggle board game. I thought it would be so easy, I touted 20 minutes to make the site. From the source code below, you can clearly see that 20 minutes is do-able – I think it may have taken me more like 45 minutes due to the little graphic and the stylesheet modifications. However, as promised, take a look at the simple source code for creating your own Boggle board game page.

<html>
<head>
 <title>devtrends.com Boggle generator</title>

 <STYLE>
 <!--
 .letterbox {
 padding:25px;
 margin:4px;
 border:1px dashed #9E7760;
 width:38px;
 text-align:center;
 background-image:url('./boggle_letter_1.jpg');
 }
 -->
 </STYLE>

</head>
<body style="background-color:#FFFFFF;">

<center>
 <table style="border:1px solid #9E7760;font-size:25px;font-family:Verdana;color:#000000;font-weight:bold;">
 <tr><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td></tr>
 <tr><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td></tr>
 <tr><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td></tr>
 <tr><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td></tr>
 <tr><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td><td><?php echo returnLetter(rand(1, 26)); ?></td></tr>
 </table>
</center>

</body>
</html>

<?php
function returnLetter($num) {
 switch ($num) {
 case 1: $returnVal = "A";break;
 case 2: $returnVal = "B";break;
 case 3: $returnVal = "C";break;
 case 4: $returnVal = "D";break;
 case 5: $returnVal = "E";break;
 case 6: $returnVal = "F";break;
 case 7: $returnVal = "G";break;
 case 8: $returnVal = "H";break;
 case 9: $returnVal = "I";break;
 case 10: $returnVal = "J";break;
 case 11: $returnVal = "K";break;
 case 12: $returnVal = "L";break;
 case 13: $returnVal = "M";break;
 case 14: $returnVal = "N";break;
 case 15: $returnVal = "O";break;
 case 16: $returnVal = "P";break;
 case 17: $returnVal = "Q";break;
 case 18: $returnVal = "R";break;
 case 19: $returnVal = "S";break;
 case 20: $returnVal = "T";break;
 case 21: $returnVal = "U";break;
 case 22: $returnVal = "V";break;
 case 23: $returnVal = "W";break;
 case 24: $returnVal = "X";break;
 case 25: $returnVal = "Y";break;
 case 26: $returnVal = "Z";break;
 }
 return $returnVal;
}
?>

About the Author

IT is not just a job but also a passion. Everything I have accomplished, both personally and professionally, has been generally entertaining, bordering on fun. Some of my projects, such as working with SharePoint Services workflow actions in Visual Studio or building a custom iSCSI SAN using the OpenSolaris, ZFS and COMSTAR, has been quite rewarding. You may think nerd...I think developing a new trend!