"PHP: Format Numbers Without Commas - No Separators"

Sandra Jun 29, 2026

Formatting Numbers in PHP Without Commas

the secret code for numbers and symbols is shown in this graphic above it's description
the secret code for numbers and symbols is shown in this graphic above it's description

When dealing with numbers in PHP, you might want to format them without commas as thousand separators. This can be particularly useful when displaying large numbers or currencies. In this article, we'll explore how to achieve this using PHP's built-in functions and some custom solutions.

What Number Formatting Means in Excel for Beginners
What Number Formatting Means in Excel for Beginners

Using number_format() Function

The `number_format()` function is the most straightforward way to format numbers in PHP. However, it adds commas as thousand separators by default. To avoid this, you can specify the number of decimal places and the thousands separator as an empty string.

331 reactions Β· 68 shares | 🟩 Alt β†’ H β†’ B β†’ A – Apply All Borders 🟩 Alt β†’ H β†’ B β†’ N – No Borders 🟩 Alt β†’ H β†’ B β†’ T – Top Border 🟩 Alt β†’ H β†’ B β†’ O – Outside Border 🟩 Alt β†’ H β†’ H – Fill Color Menu 🟩 Alt β†’ H β†’ H β†’ N | Harkesh Kumar
331 reactions Β· 68 shares | 🟩 Alt β†’ H β†’ B β†’ A – Apply All Borders 🟩 Alt β†’ H β†’ B β†’ N – No Borders 🟩 Alt β†’ H β†’ B β†’ T – Top Border 🟩 Alt β†’ H β†’ B β†’ O – Outside Border 🟩 Alt β†’ H β†’ H – Fill Color Menu 🟩 Alt β†’ H β†’ H β†’ N | Harkesh Kumar

Here's an example:

```php $number = 1234567; echo number_format($number, 0, '', ''); // Output: 1234567 ```

Using printf() Function

a computer screen showing the number format for a web page, and an email address
a computer screen showing the number format for a web page, and an email address

The `printf()` function can also be used to format numbers without commas. It's more flexible than `number_format()` as it allows you to specify the exact format of the output.

Here's an example:

```php $number = 1234567; printf("%d", $number); // Output: 1234567 ```

Formatting Large Numbers

Format Specifiers
Format Specifiers

For very large numbers, you might want to display them in a more readable format, such as "1.2M" for 1,200,000. Here's a function that can do this:

```php function formatLargeNumber($number) { $suffix = array('','K','M','B','T'); $count = 0; while ($number >= 1000) { $number /= 1000; $count++; } return round($number, 1) . $suffix[$count]; } $number = 1234567890; echo formatLargeNumber($number); // Output: 1.2M ```

Formatting Currencies

When formatting currencies, you might want to include a symbol and two decimal places. Here's an example using `printf()`:

an image of a computer screen with many lines on it and the text in white
an image of a computer screen with many lines on it and the text in white

```php $currency = 1234.56; printf("%s%.2f", '$', $currency); // Output: $1234.56 ```

Conclusion

In this article, we've explored several ways to format numbers in PHP without commas. Whether you're dealing with large numbers, currencies, or just want to remove commas from a number, PHP provides several functions to help you achieve this. Understanding these functions will allow you to display numbers in a more readable and user-friendly format.

the details page for registration number
the details page for registration number
Boston Excel Consulting
Boston Excel Consulting
Company Registration Number Format in India: Meaning, Structure, and Complete Guide
Company Registration Number Format in India: Meaning, Structure, and Complete Guide
a white poster with the words charity is professionalism
a white poster with the words charity is professionalism
a screenshot of the number proof by induction question 1 and 2 answer questions 3 - 4
a screenshot of the number proof by induction question 1 and 2 answer questions 3 - 4
an iphone screen showing the settings for contacts and numbers on their screenshots, which appear to be blocked by someone's phone number
an iphone screen showing the settings for contacts and numbers on their screenshots, which appear to be blocked by someone's phone number
Format Numbers to Thousands and Millions in Excel
Format Numbers to Thousands and Millions in Excel
a table with numbers and symbols for different types of web pages, including the wordpress
a table with numbers and symbols for different types of web pages, including the wordpress
an open notebook with writing on it
an open notebook with writing on it
an image of a document with the title and page numbers on it, in blue
an image of a document with the title and page numbers on it, in blue
Bio Data For Students, Bio Data Format For Student, How To Fill Biodata Form, Driver Resume Format, Dmv Driver License Application Form, Biodata Fill Up Form, Biodata Form With Personal Details, Marriage Biodata Format For Boy, Biodata Format Download Pdf
Bio Data For Students, Bio Data Format For Student, How To Fill Biodata Form, Driver Resume Format, Dmv Driver License Application Form, Biodata Fill Up Form, Biodata Form With Personal Details, Marriage Biodata Format For Boy, Biodata Format Download Pdf
Penggabungan Query INSERT, SEARCH, DELETE dan UPDATE - Redaksiana
Penggabungan Query INSERT, SEARCH, DELETE dan UPDATE - Redaksiana
Gray Code – Gray Code Table
Gray Code – Gray Code Table
Format Numbers In Thousands, Million Or Billions…
Format Numbers In Thousands, Million Or Billions…
an invoice sheet with the company's names and numbers
an invoice sheet with the company's names and numbers
an image of a man pointing at a screen with the text excel's secret code custom number formating unlocked
an image of a man pointing at a screen with the text excel's secret code custom number formating unlocked
the format menu with two arrows pointing to it
the format menu with two arrows pointing to it
Stencyl formatting numbers
Stencyl formatting numbers
an email form with the text, what is a routing number? when you send or receive money directly from your electronic payment
an email form with the text, what is a routing number? when you send or receive money directly from your electronic payment
a man in a suit points at a data sheet with the words stop hiding your data's meaning
a man in a suit points at a data sheet with the words stop hiding your data's meaning