Generating alphanumeric unique ID in codeigniter

Today i will show you how to generate alphanumeric unique ID using Codeigniter. Some times there is requirement to generate the unique id, But most of the time we are going to write our logic. But Codeigniter Framework Provides Helpers, which simplify our need. One of them is string Helper.

How to use CodeIgniter String Helper:

To use string helper you need to first load it, then use the random_string() function. Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.The first parameter specifies the type of string, the second parameter specifies the length.

The following choices are available: alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1

1) alpha: A string with lower and uppercase letters only.

2) alnum: Alpha-numeric string with lower and uppercase characters.

3) numeric: Numeric string.

4) nozero: Numeric string with no zeros.

5) unique: Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. Returns a fixed length 32 character string.

6) sha1: An encrypted random number based on do_hash() from the security helper.

That’s it.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x