How PHP removes 0 after the decimal point
How PHP removes 0 after the decimal point
The existing decimal 2002.001 uses PHP to remove the 1 preceding the decimal point from 0. namely: 2002.1
------Solution--------------------
What's the rule?
------Solution--------------------
It's gone, and the value has changed.
------Solution--------------------
PHP code
$num =explode (".", "2002.001"); $num [1]=str_replace ( 0, "", $num [1]); Echo implode (".", $num);
------Solution--------------------
is handled as a character, but
PHP code
$str =" 2002.001.002.12.05 "; Echo preg_replace ('/(? <=\.) [0]+/', ' ', $str];//output 2002.1.2.12.5
------Solution--------------------
Remove 0, do not change the number value, the number is still valid
------ Solution--------------------
Use the Intval function to
Echo intval (7533.725548);
Echo intval (7533.225548);
------Solution--------------------
Your clear needs! Maybe you're thinking the final result is the year of the Year "2012.2"
But when you save the data, there is an inexplicable 2 in front of the 0,right???
------Solution--------------------
Regular matches