Can i get logic to make 5 digit alpha numeric sequential string.
if number between 00001-99999, we can show the same number, but when reach 99999 it should show A00001 instead of 100000. Also after A9999 it should be B0001.
Do you have any logic to do this.
Perhaps something like this that converts the input string to base 10 ([0-9]), increases the value by 1, converts back to base 36 ([a-z0-9]) and returns the new value. It also pads the value to 5 characters for numeric values less than 10000.
function do_the_thing($string){
return str_pad(base_convert(base_convert($string,36,10)+1,10,36),5,0,STR_PAD_LEFT);
}
Testing with
echo do_the_thing('a0000');
Returns 'a0001'.
Some results after testing:
99999 -> 9999a
a9999 -> a999a
zzzzz -> 100000
Not 100% what you're looking for but quite close.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With