Jump to content

number problem


glenelkins

Recommended Posts

ok

a number is being sent with $_GET in the form: 150,000 i want to compare this with a variable containing a number. But when i use $tmp_price = explode(",",$_GET['pricemax']) the result is not how i would expect, ie $tmp_price[0] = 150 $tmp_price[1] = 000 ... was then going to put them together are 150000

Any ideas?
Link to comment
https://forums.phpfreaks.com/topic/21420-number-problem/
Share on other sites

What's the format that you have in the variable, is it 150,000 or just 150000?

If it's just a case of removing the delimiter, then use [url=http://uk.php.net/manual/en/function.str-replace.php]str_replace()[/url]

[code]$maxprice = str_replace(",", "", $_GET['maxprice']);[/code]

Regards
Huggie

[size=8pt][color=red][b]EDIT:[/b][/color][/size] Too slow :(!
Link to comment
https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95407
Share on other sites

[quote author=glenelkins link=topic=108799.msg438016#msg438016 date=1158764475]
ok

a number is being sent with $_GET in the form: 150,000 i want to compare this with a variable containing a number. But when i use $tmp_price = explode(",",$_GET['pricemax']) the result is not how i would expect, ie $tmp_price[0] = 150 $tmp_price[1] = 000 ... was then going to put them together are 150000

Any ideas?
[/quote]

If you do want to split it up you could do this: [code]<?php
$number = explode(',',$_GET['pricemax']);
$number = join('',$number);
?>[/code]

The other option you have been showed is better though.
Link to comment
https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95413
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.