in reply to adding 1 to a char of 1
Use the string increment operator:
$newfile = "0001"; # Initialize to 0001 ++$newfile; # Now contains 0002
Same thing, but longer:
$newfile = "0001"; # Initialize to 0001 $newfile = sprintf("%04d", $newfile+1); # Now contains 0002
If you just want 2 as opposed to 0002, then it's just:
$newfile = "0001"; # Initialzie to 0001 $newfile += 1; # Now contains 2
|
|---|