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
2
Medium Priority
?
379 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 150 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

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

885 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