Replace last few digit to zero
math, php
Solution
One potential solution: divide by 1000, convert to a whole number, and then multiply by 1000 again.
$x = 2746345;
echo floor($x/1000)*1000; //prints 2746000
Problem
What is the cleanest way to replace last few digit of a number to zero in PHP Example of replace last three digit: 2746345 -> 2746000 67200 -> 67000 Note : This is not rounding off