-3

I would like to generate an auto increment invoice number using prefix.

Digits: 11 Prefix: B

From: B0000000001 to B0000000020.

Is there a easy way to do this in PHP?

Dany Bullet
  • 1
  • 1
  • 2

1 Answers1

0

This is how you can do in in php.

$index = 11;
$prefix = 'B';
echo sprintf("%s%011s", $prefix, $index);
Jason K
  • 1,406
  • 1
  • 12
  • 15
  • `echo sprintf()` is an "antipattern". There is absolutely no reason that anyone should ever write `echo sprintf()` -- it should be `printf()` without `echo` every time. – mickmackusa Apr 16 '22 at 03:21