Jump to content

how to have 20 "rand" in 1 string?


Driiper

Recommended Posts

not sure what you want to do, but you can set rand to give a random number between 2 numbers.

 

$random = rand(0, 100);

 

now you will get a random number between 0 and 100.

 

If that is not what you were looking for then please explain a little better. Or give an example of what you want to accomplish.

 

Ray

@ucffool - Won't work like that... From the manual:

 

If called without the optional min , max  arguments rand()  returns a pseudo-random integer between 0 and RAND_MAX

 

 

This should work:

<?php

$string = '';
for ($x=0; $x<20; $x++)
  $string .= rand(0,9); // concatenate onto string the result of rand()
echo $string;

?>

 

 

Orio.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.