Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
How to generate unique random numbers using php
Mohammed Adamu
Feb 20 2017 9:34 PM
384
Reply
Please i need help on how to generate highly unique id for my php program, i have one which is doing that but after about 190 unique numbers it started to repeat itself which is making the unique column in the database problematic. please here is my code code if there is something i did wrong please help me correct it thanks. "
function uniqids() {
$chars = "003232303232023232023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$finalcode='RS-'.uniqids();
"
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
How to POST value to PHP in the same page using jQuery
how to send mail in php