PHP Classes

File: helper/gen_rand_string.php

Recommend this page to a friend!
  Classes of Alexey Starikov   PHP Helper Class   helper/gen_rand_string.php   Download  
File: helper/gen_rand_string.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Helper Class
Call helper functions that are loaded dynamically
Author: By
Last change:
Date: 5 years ago
Size: 360 bytes
 

Contents

Class file image Download
<?php
# gen_rand_string
return function ($length, $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
{
   
mt_srand((double)microtime() * 1000000); #?????????????
   
$r = '';
   
$l = strlen($chars);
    for (
$i = 0; $i < $length; $i++)
    {
       
$r .= substr($chars, mt_rand(0, $l - 1), 1);
    }
    return
$r;
}
?>