View Single Post
Old 06-28-2012, 06:36 PM   PM User | #9
helen11
New Coder

 
Join Date: Nov 2011
Location: South Africa
Posts: 46
Thanks: 12
Thanked 0 Times in 0 Posts
helen11 is an unknown quantity at this point
This is what I have but im not sure if its right.

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Dice Roll</title></head>
<body>

<?php
$rolls 
26;
$results = array(=> array(), array(), array(), array(), array(), array());
$total 0;

for (
$i=1;  $i <= $rolls; ++$i) {
    
$val rand(1,6);
    
$results[$val][] = $i;
    
$total += $val;
}

echo 
"<table border='1'>";
echo 
"<tr><th>Roll Number</th><th>Throws</th><th>Roll Value</th></tr>";

foreach (
$results as $val => $throws) {
    echo 
"<tr><th>$val</th><td>" join(', '$throws) ."</td><td>" count($throws) . "</td></tr>";
}

echo 
"</table><br />";
printf ('Total : %d, Average: %4.2f'$total$total/$rolls);
?>
</body>
</html>
helen11 is offline   Reply With Quote