Solved

Add commas to a digit

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now