Mahdi.Pishguy Mahdi.Pishguy - 9 months ago 39
PHP Question

PHP remove last zero from integer by substr

in php i get some values from database as integer, now i want to remove last zero from

integer, but me below code doesnt work.

$payerd_amount = 20000000;
$payerd_amount = substr((string)$payerd_amount,1,strlen((string)$payerd_amount) -1);

how to do this action? my code seems correct but after substring i get this result:



If all you want to do is remove the last zero, just divide by 10

   $payerd_amount = $payerd_amount / 10;

This works, too:

   $payerd_amount = substr($payerd_amount, 0, -1);