Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# How to turn 15000 into 150.00 - Inserting decimal point .

Posted on 2006-11-22
Medium Priority
379 Views
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
Question by:ManicZoot

LVL 9

Accepted Solution

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

Author Comment

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

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
###### Suggested Courses
Course of the Month10 days, 23 hours left to enroll