Want to remove all 0 placed at the beginning of some variable.
Some options:
$var = 0002, we should strip first 000 ($var = 2)var = 0203410 we should remove first 0 ($var = 203410)var = 20000 - do nothing ($var = 20000)What is the solution?
cast it to integer
$var = (int)$var;
                        Maybe ltrim?
$var = ltrim($var, '0');
                        $var = ltrim($var, '0');
This only works on strings, numbers starting with a 0 will be interpreted as octal numbers, multiple zero's are ignored.
$var = strval(intval($var));
or if you don't care about it remaining a string, just convert to int and leave it at that.
Just use + inside variables:
echo +$var;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With