php remove leading zeros

Posted by w3diy - 1 year ago

How to remove all leading zeros in a string in PHP ?

remove/delete all leading zeros from the given string using PHP.

Example 1:

<?php 
$money = "00986205"; 
$money = ltrim($money, "0"); 
echo $money; 
?> 

Example 2:

<?php 

$money = "00986205"; 
$money = (string)((int)($money));     
echo $money; 

?>