Home>Article>Backend Development> How to remove commas from numbers in php

How to remove commas from numbers in php

藏色散人
藏色散人 Original
2021-09-03 10:58:53 4734browse

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.

How to remove commas from numbers in php

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.37

number_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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn