How to remove commas from numbers in php

藏色散人
Release: 2023-03-12 10:56:01
Original
4719 people have browsed it

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");
Copy after login

Output:

10000000000.00
Copy after login

str_replace() function replaces some characters in the string with other characters (differentiate uppercase and lowercase).

Second method example:


        
Copy after login

Output:

1235.37
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!