- rand: documentation ( source)
<?php
$factor=6;
for($x=0; $x<10; ++$x){ // battery of 10 tests
$number=rand(0,100);
echo "Number: $number Becomes: ";
if($remainder=$number%$factor){ // if not zero
$number+=$factor-$remainder; // use cached $remainder instead of calculating again
}
echo "$number\n";
}