/ Published in: PHP
For a project I needed to generate a unique code for each user the client would input manually. Each user would have four fields (first name, last name, email, zipcode). Omitting the email addresses ensures unique output because we reduce the chances of characters like; '@', '.', and strings like 'com' being reused everytime. It's simple, it's efficient and it's not overcomplicated.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//unique is built by concatenating the user input (first, last, zip) function makeCode($unique) { //specify output string length $length = 5; //start with empty sting $string = ''; for ($i = 0; $i < $length; $i++) { } return $string; }