jhl84
02-02-2007, 07:11 AM
Hi guys, i have this number, 878777886XXXXXX. The Xs represent random numbers that I want to generate. I want to generate 1000 numbers that does not repeat using php. can anyone help?
thanks!
thanks!
|
||||
How to Generate Random Numbers?jhl84 02-02-2007, 07:11 AM Hi guys, i have this number, 878777886XXXXXX. The Xs represent random numbers that I want to generate. I want to generate 1000 numbers that does not repeat using php. can anyone help? thanks! _Aerospace_Eng_ 02-02-2007, 07:31 AM We can but don't expect us to just give you the code. What exactly have you tried? raf 02-02-2007, 12:47 PM this $arr_randoms = array(); $i = 0; do { $val = '878777886' . mt_rand(1,999999); if (!array_key_exists($val, $arr_randoms)) { $arr_randoms[] = $val; $i ++; } }while($i < 1000); would generate an array with 1000 unique, random, elements (stat start with 878777886). maybe there is a shorter/faster way --> who improves or comes with a more performant alternative? |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum