PHP random string generator function

Jimmy Wales Reply 15:46
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomStringValue = '';
    for ($i = 0; $i < $length; $i++) {
        $randomStringValue .= $characters[rand(0, strlen($characters) - 1)];    }
    return $randomStringValue ;}
Output the random string :-
// Echo the random string.
echo generateRandomString(); 

Related Posts

PHP 3468667307209317406
Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us