How does php remove the 0php after the decimal point? How does PHP remove the 0php after the decimal point? 2002.001 how does php remove the zero before the decimal point. That is: 2002.1 ------ solution ------------------ what is the rule? ------ Solution ------------------ removed, and the value also changed ------ solution -------------------- PHP php how to remove 0 after the decimal point
How does php remove 0 after the decimal point?
How to remove the zero before the first decimal point in PHP with a decimal point of 2002.001. That is, 2002.1
------ Solution --------------------
What's the rule?
------ Solution --------------------
Removed, and the value has changed.
------ Solution --------------------
PHP code
$ Num = explode (". "," 2002.001 "); $ num [1] = str_replace (0," ", $ num [1]); echo implode (". ", $ num );
------ Solution --------------------
Can be processed as characters.
PHP code
$ Str = "2002.001.002.12.05"; echo preg_replace ('/(? <= \.) [0] +/', '', $ str); // output 2002.1.2.12.5
------ Solution --------------------
If the value of 0 is removed, the numeric value will not be changed. is the number still valid?
------ Solution --------------------
Use the intval function.
Echo intval (7533.725548 );
Echo intval (7533.225548 );
------ Solution --------------------
Your need is clear! Maybe the final result you want is the year and month (2012.2]
But when you store data, there are 0, right ???
------ Solution --------------------
Regular Expression Matching