Return to Snippet

Revision: 31031
at August 27, 2010 15:58 by jamepaul


Initial Code
<?php 
/************* 
 *@l - length of random string 
 */  
 function generate_rand($l){  
   $c= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";  
   srand((double)microtime()*1000000);  
   for($i=0; $i<$l; $i++) {  
      $rand.= $c[rand()%strlen($c)];  
   }  
   return $rand;  
 }
?>

Initial URL
http://webdeveloperplus.com/php/21-really-useful-handy-php-code-snippets/

Initial Description
Useful snippets for php developers.

Initial Title
Generate a random string

Initial Tags
php

Initial Language
PHP