I want to generate a serial key with this pattern :
DA-7470-20762
and this is what I have done so far :
$code = strtoupper(md5(uniqid(microtime(true), true)));
$uuid = sprintf("%02s-%04o-%04o",
$code[0].$code[1],
$code[2].$code[3].$code[4].$code[5],
$code[6].$code[7].$code[8].$code[9]
);
But I want to prevent serial keys like this :
AB-0000-0001
I need to remove all 0’s, because they are so predictive.
Is there a way to set range for octal sprintf like [1-9]?
I’d probably go with something along these lines: