?
Solved

Add commas to a digit

Posted on 2007-03-19
2
Medium Priority
?
311 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 260 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 240 total points
ID: 18752906
$number = 150000;
print number_format($number/100, 2, ',', '');
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 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