Generating random strings within PHP
Published on 8/19/2008 by Dotnetindex|
Vote this tutorial:
|
More articles in PHP
You may use this code snips to make your own random passwords or any other random strings. In this tutorial we need to use two functions of PHP: rand() and chr() .
Exactly rand() function generates a random integer.
Description of rand() int rand ( int $min , int $max )
Description of chr() string chr ( int $ascii )
This function returns an interger, so we can call chr function to return an ASCII character. So let's get only one length string:
<?php chr(rand(97,122)) ?>
This will return only one characte. In ASCII list non-capital english characters listes between 97-122. A complete list of ASCII characters can be found on google. Capital englisg characters listed between 65-90.
happy coding
Comments:
no comments submitted
Latest Posts
- Database driven web counter with PHP/mySQL
- PHP mail() function
- Workingwith Arrays in PHP
- Check if the domain name exists
- Generating random strings within PHP
- Encode/Decode an ISO-8859-1 string to UTF-8
- Creating error pages using .htaccess
- PHP Security
- Displaying mySQL table structures in PHP
- Capitilize strings in PHP
- Counting records in PHP mySQL
- Parsing XML/RSS feeds easily with SimpleXML
- Sending queries to mySQL
- Session in PHP
- MD5 Encryption in PHP
- PHP Functions array fill
- How to display date time in real time
- PHP Functions urlencode
- In Case You Missed ItThe Week of January 23 2006
- In Case You Missed ItThe Week of January 16 2006


