Solved

How to turn 15000 into 150.00 - Inserting decimal point .

Posted on 2006-11-22
2
365 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
Comment Utility
Could you not just divide by 100?
0
 

Author Comment

by:ManicZoot
Comment Utility
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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

10 Experts available now in Live!

Get 1:1 Help Now