Return to Snippet

Revision: 37337
at December 8, 2010 14:36 by Arvi


Updated Code
//------------------------------------------------------------------------------------------
/*
 * Create numeric token
 */
private function createNumericToken($max_loop=210)
{
    $token = null;
    for($i=0; $i < $max_loop; $i++)
    {
        $token .= mt_rand(0, 9);
    }

    return $token;
}

//------------------------------------------------------------------------------------------
/*
 * Create alphanumeric token
 */    
private function createAlphanumericToken($max_loop=5)
{
    $token = null;
    for($i=0; $i < $max_loop; $i++)
    {
        $token .= md5(uniqid());
    }

    return $token;
}

Revision: 37336
at December 8, 2010 14:35 by Arvi


Updated Code
//------------------------------------------------------------------------------------------
/*
 * Create numeric token
 */
public function createNumericToken($max_loop=210)
{
    $token = null;
    for($i=0; $i < $max_loop; $i++)
    {
        $token .= mt_rand(0, 9);
    }

    return $token;
}

//------------------------------------------------------------------------------------------
/*
 * Create alphanumeric token
 */    
public function createAlphanumericToken($max_loop=5)
{
    $token = null;
    for($i=0; $i < $max_loop; $i++)
    {
        $token .= md5(uniqid());
    }

    return $token;
}

Revision: 37335
at December 8, 2010 14:32 by Arvi


Updated Code
//--------------------------------------------------------------------------------------
    /*
     * Create numeric token
     */
    private function createNumericToken($max_loop=210)
    {
        $token = null;
        for($i=0; $i < $max_loop; $i++)
        {
            $token .= mt_rand(0, 9);
        }

        return $token;
    }

    //--------------------------------------------------------------------------------------
    /*
     * Create alphanumeric token
     */    
    private function createAlphanumericToken($max_loop=5)
    {
        $token = null;
        for($i=0; $i < $max_loop; $i++)
        {
            $token .= md5(uniqid());
        }

        return $token;
    }

Revision: 37334
at December 8, 2010 14:23 by Arvi


Initial Code
//large random alphanumeric
$random_alphanum = null;
for($i=0; $i < 7; $i++)
{
    $random_alphanum .= md5(uniqid());
}


//large random numeric
$random_num = null;
for($i=0; $i < 210; $i++)
{
    $random_num .= mt_rand(0, 9);
}

Initial URL

                                

Initial Description
Attempt to generate random numbers or random alphanumerics

Initial Title
Generating random numbers and alphanumerics

Initial Tags

                                

Initial Language
PHP