Monday, March 28, 2011

Generate Random 10 digit String


function genRandomString($length) {
    //$length = 10;
    $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
    $string = '';  
    for ($p = 0; $p < $length; $p++)
{
        $string .= $characters[mt_rand(0, strlen($characters))];
    }
    return $string;
}

   echo strtoupper(genRandomString(10));

No comments:

Post a Comment