How to remove all leading zeroes in a string
you can add "+" in your variable,
example :
$numString = "0000001123000";
echo +$numString;
(string)((int)"00000234892839")
Similar to another suggestion, except will not obliterate actual zero:
if (ltrim($str, '0') != '') {
$str = ltrim($str, '0');
} else {
$str = '0';
}
Or as was suggested (as of PHP 5.3), shorthand ternary operator can be used:
$str = ltrim($str, '0') ?: '0';
ltrim
:
$str = ltrim($str, '0');