When I do this..
$a = "00";
$b = $a+6;
echo $b;
Output is 6, but I need output 06 "with leading zero".
The leading zero I need if the + number ist between 1-9.
I don’t figured out how I can do this, I’ve tried everything possible, the output is always
3 or 6 or 8 without zero.
How I can do this? where is the trick?
Thank you!
>Solution :
You can use:
$b = $b < 10 ? "0$b" : $b;
echo $b;