$width = 4; $number = substr(sprintf("%0${width}d", $number + 1), -$width);