Jump to content

Decimals & Leading Zero Question


Kon-Tiki
 Share

Recommended Posts

Hey,I got some numbers to perform some basic maths on. Little problem with it, is that some numbers are regular ints, while others look like this: "1,234". If I do those maths on the latter type, they'll lose everything after the comma. I want to keep everything behind the comma as well, though.Also, they have leading zeroes. How can I keep those as well?Thanks in advance,Kon-Tiki

Edited by Kon-Tiki
Link to comment
Share on other sites

You can use intval or floatval to convert a numeric string to a number. intval or floatval stops at a comma, so before using those you can use str_replace to remove the commas. You can use number_format to format a number with grouped thousands, and use str_pad to pad zeros on the left.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...