Answers for "generate random stringù php"

PHP
3

randomstring php

//generates 13 character random unique alphanumeric id
echo uniqid();
//output - 5e6d873a4f597
Posted by: Guest on June-08-2020
1

random string generator php

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

Output the random string with the call below:

// Echo the random string.
// Optionally, you can give it a desired string length.
echo generateRandomString();
Posted by: Guest on July-11-2020

Code answers related to "generate random stringù php"

Browse Popular Code Answers by Language