|
Sprintf would be a waste in this case, and the second example makes three calls to one function. You could use number_format() or any one of those *EDIT* string */EDIT* functions, but *EDIT* they'll just waste processor time */EDIT*.
Option 1. quick and concise
$rand = rand(0,9).'.'.rand(99,999);
Option 2. normally quicker than #1 if your *only* going to echo
echo rand(0,9),'.',rand(99,999);
Option 3. Quicker than any of the above, and simple. I bet you thought basic math would never be useful.
$rand = rand(0,999)/10;
:P
~capiCrimm
Last edited by capiCrimm; 09-16-2005 at 11:15 PM..
|