How To Create a Unique Number Containing text with fixed digits Number Like AB000012?

How To Create a Unique Number Containing text with fixed digits Number Like AB000012?

 

# For 10 digits String
 $num = sprintf('%010d', 12); 
 example: 0000000012


# For 8 digits String
 $num = sprintf('%08d', 12); 
 example: 00000012


# For Create Text base Number
 $str = "AB".$num;
 example = "AB0000000012" or "AB00000012"



OR

$unique_num = 'AB'.sprintf('%08d', 12);
example = "AB0000000012"

Leave a Reply

Your email address will not be published. Required fields are marked *