easy graphical dice generator in PHP
Just a simple little script which displays two die on screen. The faces are generated randomly, and are text-based, so no images required.
<html>
<head><title>Dice</title><head>
<body>
<?php
//Required code: This defines the dice array
$dice=array(
'<br> · <br> ',
'·<br><br> ·',
'·<br> · <br> ·',
'· ·<br><br>· ·',
'· ·<br> ·<br>· ·',
'···<br><br>···',
);
//End required code
?>
<!--FONT FOR CORRECT DISPLAYING-->
<font face='Lucida Console'>
<!--TABLE FOR MULTIPLE DICE-->
<table border='1'>
<tr>
<td><!--OUTPUT-->
<?php echo $dice[array_rand($dice)]; ?>
</td>
<td><!--OUTPUT-->
<?php echo $dice[array_rand($dice)]; ?>
<!--END EVERYTHING-->
</td>
</tr>
</table>
</font>
</body>
</html>
Very cool, I like. Mind if I mention this on my new blog with a reference back to you?
- Robbie
No problem. I did acquire it a few years ago, but I can’t remember if I found it intact, or pulled it together based out of multiple sources.