How to turn 15000 into 150.00 - Inserting decimal point .

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.


15000 = 150.00
1234 = 12.34
8650 = 86.50

How can I do this with php?
Who is Participating?
olifaragoConnect With a Mentor Commented:
Could you not just divide by 100?
ManicZootAuthor Commented:
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 ;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.