Kishan Kishan - 1 year ago 62
PHP Question

Unique key generate with digit and letters in php

I need to generate unique key in php.

The key must be min 8 digit and 4 letters contain.

So any one have idea ?

Thanks you

Answer Source

Try this one


    $digit ="1234567890";
    $chars ="abcdefghijklmnopqrstuvwxyz";
    for($i=0;$i<$digit_length; $i++)
        $final_rand[]= $digit[ rand(0,strlen($digit)-1)];
    for($j=0;$j<$chars_length; $j++)
        $final_rand[]= $chars[ rand(0,strlen($chars)-1)];

    $new_array = $final_rand;

        echo $new_array[$i];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download