I have a variable(database column value) which value is look like below.
ALI-0001
now i wanna auto increment this code like ALI-0002, ALI-0003,ALI-0004,ALI-0005 every time i insert new data. I tried the following code.
$project_code = $a[0]->project_code;
$integer = (integer) substr($max_issue_number, 4);
$sum = $integer+1;
$issue_number = $project_code.'-000'.$sum;
Your solution is str_pad
ref: http://php.net/manual/en/function.str-pad.php
So your code should be as below:
$issue_number = $project_code.'-'.str_pad($sum, 4, '0', STR_PAD_LEFT);