Home>Article>Backend Development> How to remove commas from numbers in php
php method to remove commas from numbers: 1. Use the str_replace function to remove commas from numbers; 2. Use the number_format function to remove commas from numbers.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
php How to remove commas from numbers?
First method example:
echo str_replace(",","","10,000,000,000.00");
Output:
10000000000.00
str_replace() function replaces some characters in the string with other characters (differentiate uppercase and lowercase).
Second method example:
Output:
1235.37number_format() function formats a number by grouping by thousands.
Note: This function supports one, two or four parameters (not three).
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to remove commas from numbers in php. For more information, please follow other related articles on the PHP Chinese website!