jeudi 16 mars 2017

PHP: (not so) random variable

I want to make a small script what generates the barcode is the barcode field is empty. I want the barcode to be = 21xxxxxxxx and the x-es are random int numbers (min 0 max 9)

So far my code is:

if ($barcode = NULL) {
    Array($a);
    for ($i=3;$i<10;$i++){ 
        $a = rand(0,9);
    }
print_r($a);
$barcode = 21$a[3-10];
}

What's wrong with this code?




Aucun commentaire:

Enregistrer un commentaire