/ Published in: PHP
Random function, thanks to (http://boallen.com/php-get-true-random-number.html "Bo Allen")
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Returns a true random number from RANDOM.ORG's integer * http interface. Requires cURL. * * @author Bo Allen * @param int $min (Optional) Minimum number (default 1) * @param int $max (Optional) Maximum number (default 100) * @return mixed Random number (int) on success, * error or message (string) on failure */ function get_true_random_number($min = 1, $max = 100) { // Validate parameters $max = ((int) $max >= 1) ? (int) $max : 100; $min = ((int) $min < $max) ? (int) $min : 1; // Curl options CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_USERAGENT => 'PHP', CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, ); // Curl init & run . $min . '&max=' . $max . '&col=1&base=10&format=plain&rnd=new'); }