Solved

How to turn 15000 into 150.00 - Inserting decimal point .

Posted on 2006-11-22
2
369 Views
Last Modified: 2013-12-12
Hi there,

I've looked at a few functions in php but when it comes to decimal places they seem to add the decimal to the end.
Here I want to add the decimal before the last two numbers in a string.

So

15000 = 150.00
1234 = 12.34
8650 = 86.50
etc.

How can I do this with php?
0
Comment
Question by:ManicZoot
2 Comments
 
LVL 9

Accepted Solution

by:
olifarago earned 50 total points
ID: 17997307
Could you not just divide by 100?
0
 

Author Comment

by:ManicZoot
ID: 17997541
Yes that would be right :p ....  Was looking at it the wrong way.

Ok here it is

$number = 1500000000 ;
$price = $number / 100 ;
$price = number_format($price, 2, '.', ',');
echo $price ;

0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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.
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.

777 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