Popular Articles | Latest Articles | Categories | RSS Feeds

Login  |  Register

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


Only members can write comments.Please, login / register to write comment.

Latest Posts

Active News Manager - news management system



ASP.NET Resources, Reviews

ASP Resources, Reviews

PHP, ASP, .NET, JSP Resources, Reviews




Who's online

  • There 42 online users.

ASP.NET Resources, Reviews

ASP Resources, Reviews

PHP, ASP, .NET, JSP Resources, Reviews

Hotscripts.com Free Photoshop, Flash and 3DS MAX tutorials