i am trying to generate a barcode
this has to be 36 Charachters long
how does one go about getting the code to randomise and be the corect number of charaters long?
have got the random bit working fine, just not the characters
David
$number = ''; for ($i = 0; $i < 36; $i++) { $digit = rand(0, 9); $number .= $digit; } echo $number;
To include letters:
$alpha_arr = range(a, z); $digit_arr = range(0, 9); $char_arr = array_merge($alpha_arr, $digit_arr); $str = ''; for ($i = 0; $i < 36; $i++) { $char = $char_arr[rand(0, count($char_arr) - 1)]; $str .= $char; } echo $str;
thats brill cheers installer
😃