Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $rand1 = 0; $rand2 = 0; $rand3 = 0; $rand4 = 0;
- $rands = array();
- for ($x = 1; $x <= 100; $x++) {
- $rand = mt_rand(1, 4); // random chose
- // Stats - increment based on chosen random
- switch ($rand) {
- case '1': $rand1++; break;
- case '2': $rand2++; break;
- case '3': $rand3++; break;
- case '4': $rand4++; break;
- }
- array_push($rands, $rand); // add rand result to array
- }
- // echo stats
- echo("<pre>Total Rands: ".count($rands)."</pre>");
- echo("<pre>Rand1: (".$rand1.") | Rand2: (".$rand2.") | Rand3: (".$rand3.") | Rand4: (".$rand4.")</pre>");
- // echo results
- $rand = 0;
- $td_cnt = 0;
- foreach ($rands as $r) { // loop array - build columns
- $rand++; // increment
- $td_cnt++; // increment
- IF ($td_cnt == 1) { echo("<div style=\"width:200px; float:left;\">"); }
- echo("<pre>rand(".$rand."): ".$r."</pre>");
- IF ($td_cnt == 25) { echo("</div>"); $td_cnt = 0;}
- IF ($rand == 100) { echo("</div><div style=\"clear:both;\"></div>"); }
- }
- // dump array
- echo("<pre><strong>Array Dump</strong></br>".print_r($rands, true)."</pre>");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement