Solved

Add commas to a digit

Posted on 2007-03-19
2
307 Views
Last Modified: 2013-12-13
I have a number : 150000 where the last two digit are the decimals, I need to add a comma before the last two digit to show the correct amount as follow 1500.00
0
Comment
Question by:willygonzalez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
richdiesal earned 65 total points
ID: 18752893
What about just using:

$number = $number / 100;

You can then display the number, forcing 2 decimal places, using:

printf("%0.2f", $number);
0
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 60 total points
ID: 18752906
$number = 150000;
print number_format($number/100, 2, ',', '');
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question