lundi 28 juin 2021

I need help generating random sku code in php language

I have this function but can't get the output like this. Please help me to get this result RMXZ-MIGX-DYUJ-YVJM

function randomString()
{
    $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randstring = '';
    for ($i = 0; $i < 10; $i++) {
        $randstring = $characters[rand(0, strlen($characters))];
    }
    return $randstring;
}
echo randomString(); // output: A or B or ....Z

Thank you very much




Aucun commentaire:

Enregistrer un commentaire