Kon-Tiki Posted October 19, 2009 Report Share Posted October 19, 2009 (edited) 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 October 19, 2009 by Kon-Tiki Link to comment Share on other sites More sharing options...
justsomeguy Posted October 19, 2009 Report Share Posted October 19, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now