Link to home
Start Free TrialLog in
Avatar of pixelscape
pixelscape

asked on

Shorten variable to 100th decimal place


I have a variable, $item_price, whose value is 55.0000

I want to shorten the number to the 100th place. I was trying to do the following but do not get output when I echo $item_price2. I wonder if I need to convert this value from a string to a number?? Thoughts?


$item_price2 = number_format($item_price, 2, '.', '');
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

"I want to shorten the number to the 100th place...."

Do you really want 100 decimal places? Or do you mean 2 decimals? The code you have posted should work for 2 decimals. What happens when you run the script?
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pixelscape
pixelscape

ASKER

Thanks mankowitz. That was it.