converting 1,599.12 to a float value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

converting 1,599.12 to a float value

Post by pelegk2 »

i tried to convert 1,599.12 to a float number using floatval()
but the value i get is 2!!!!
why is that?
what to do?
thnaks in advance
Peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

does the value you are trying to convert have the comma? .. remove it.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

yes it does

Post by pelegk2 »

i finally removed the comma
but isnt there any way withogut removing the comma?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not really.. commas aren't apart of decimal numbers as far as php is concerned. They are an addition by humans to make it easier on us.
Post Reply