Random number generated and divided in to 3 numbers randomly in php -
Random number generated and divided in to 3 numbers randomly in php -
this question has reply here:
how create 5 random numbers sum of 100 7 answerscan random number beingness generated , split/divided allow 3 individual numbers randomly in php? (so add together random number)
basically have random number (range 0 15)
for example:
there 14 available now - 2 in gotham city - 8 in lakeview hills - 4 in eskimoville
(just dummy give idea)
isn´t there simple approach accomplish this?
have nice weekend!
basic implementation need error checking + not 100% random
<?php //first initial number // range must 3-15 3 random additions $i = rand(3,15); echo $i; // generate 3 number adds $i $one = rand(1,$i-2); $i-=$one; $two = rand(1,$i-1); $i -= $two; $three = rand(1,$i); $i -= $three; if($i > 0){ // add together remained 3rd number $three += $i; } echo $one; echo $two; echo $three; ?>
php
Comments
Post a Comment