Incrementing numbers starting from 0000 in php
numbers, php
Solution
$n2 = str_pad($n + 1, 5, 0, STR_PAD_LEFT);
Use `str_pad()` by adding `0`s (third parameter) to the left (fourth parameter) of the old number `$n` incremented by `1` (first parameter) until the length is 5 (second parameter).
Problem
I need a suggestion on a function for a php counter. Is there any function to have numbers with 5 digit as 00001, or 00123… this number should be not random but have to increase the value of a previous field. If a number is $n=’00001’ there is a function to increase by one and get 00002 and not 2? Thanks F.