adam84 Posted March 17, 2007 Share Posted March 17, 2007 I need 'x' amount of random numbers, when i use the code below I always get the same results. Is there a better or different way of doing it? for( $i = 0; $i 5; $i++){ $time = time(); $length = 10; srand(date("s")); $possible_charactors = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $ticketNum = ''; while(strlen($ticketNum )<$length) $ticketNum .= substr($possible_charactors, rand()%(strlen($possible_charactors)),1); echo $ticketNum. "<BR>"; } Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2007 Share Posted March 17, 2007 You dont need to initialize with the srand() function anymore. Remove that line. You dont' need this line: <?php $time = time(); ?> either. Ken Quote Link to comment Share on other sites More sharing options...
shaunrigby Posted March 17, 2007 Share Posted March 17, 2007 use rand(min no,max no) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.