Increment a value with leading zeroes using php and those numbers must be from counts in the database. For example 0001 to 1000.
C style increment and decrement operators represented by ++ and -- respectively are defined in PHP also. As the name suggests, ++ the increment operator increments value of operand variable by 1. The Decrement operator -- decrements the value by 1. Both are unary operators as they need only one operand.
use str_pad()
$val = 1;
echo str_pad($val,4,"0",STR_PAD_LEFT); // 0001
$val = 10;
echo str_pad($val,4,"0",STR_PAD_LEFT); // 0010
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