?
Solved

How to turn 15000 into 150.00 - Inserting decimal point .

Posted on 2006-11-22
2
Medium Priority
?
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

770 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