Dice Rolling Simulator
<?php
function roll_dice($number, $sides, $values = false) {
$dice = array();
for ($i = 0; $i < $number; $i++) {
$dice[] = rand(1, $sides);
}
if ($values) {
return $dice;
} else {
return array_sum($dice);
}
}
$roll_3d6 = roll_dice(3, 6);
echo "<pre>Dice roll = {$roll_3d6}\n";
$rm_stats = roll_dice(10, 100, true);
print_r($rm_stats);
echo '</pre>';
?>
Related examples in the same category