|
|
|
| Title : |
Easy to use random number function that seeds with uniqid and allows a max value |
| Categories : |
Math., PHP |
 Stefan Powell |
| Date : |
Jul 14th 1998 |
| Grade : |
2 of 5 (graded 3 times) |
| Viewed : |
5914 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Stefan Powell |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
function random($max = 1) {
static $startseed = 0;
if (!$startseed) {
$startseed = (double)microtime()*getrandmax();
srand($startseed);
}
return ((rand()/getrandmax())*$max);
}
$bar = 200;
$foo = random($bar);
echo "$foo is a random number between 0 and $bar.";
?> |
|
| Latitude-Longitude to Miles Categories : PHP, Utilities, Math. | | | Math operations on big numbers Categories : PHP, Math. | | | Diffusion-Limited Aggregation visualization Categories : PHP, Graphics, Algorithms, Math. | | | Reverse a given number Categories : PHP, Beginner Guides, Algorithms, Math. | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Easy to use random number function that returns an integer Categories : Math., PHP | | | decoct -- Decimal to octal Categories : PHP, PHP Functions, Math. | | | Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other? Categories : PHP, Math., Arrays | | | Show the steps for converting a number from a given base to base 10. Shows the steps involved in converting a number from a given base to base 10. Categories : PHP, Math., Algorithms | | | Temperature Conversion Categories : PHP, Math., Beginner Guides | | | How to judge if an integer is odd or is even in Php3? Categories : Math., PHP, Algorithms | | | Calculator for Baroque Violin strings Categories : Math., PHP, Strings | | | Arbitrary Precision Math using BCMATH routines Categories : PHP, Math., BC math | | | Greatest Common Denominator - A simple class that finds the greatest common denominator for two integers.
Categories : PHP, PHP Classes, Math. | | | grab the result of any calculation you submit to the Google Calculator. Categories : PHP, Arrays, Web Services, Regexps, Math. | |
|
|