How to generate random character strings in a range in PHP?

Share Button

Sometimes you may need to generate random strings, such as different passwords. This article tries to show you some tricks to generate different random strings in PHP.

The following function acctepts one argument $length which is number of characters on the return word. You can change the arguments to get your need.


I have been developing web sites since 2004 and currently working in London as a Senior Web Developer with responsibility for PHP/MySQL backend systems and jQuery frontend development. My ulitmate focus is on server side programming, release process, automation, and standards based web site design especially on Zend Framework. I also have a keen interest in developing Wordpress plugins and contributing to open source projects.

Leave a Comment

Your email address will not be published. Required fields are marked *