Solved

Add commas to a digit

Posted on 2007-03-19
2
309 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
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.

717 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