glenelkins Posted September 20, 2006 Share Posted September 20, 2006 oka 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 150000Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/21420-number-problem/ Share on other sites More sharing options...
glenelkins Posted September 20, 2006 Author Share Posted September 20, 2006 ? Quote Link to comment https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95393 Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 Rather than exploding the comma and then stiching the number back together. Use str_replace:[code=php:0]$tmp_price = $_GET['pricemax'];// remove any commas from price max.$price = str_replace(',', '', $tmp_price);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95404 Share on other sites More sharing options...
HuggieBear Posted September 20, 2006 Share Posted September 20, 2006 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]RegardsHuggie[size=8pt][color=red][b]EDIT:[/b][/color][/size] Too slow :(! Quote Link to comment https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95407 Share on other sites More sharing options...
Daniel0 Posted September 20, 2006 Share Posted September 20, 2006 [quote author=glenelkins link=topic=108799.msg438016#msg438016 date=1158764475]oka 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 150000Any 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. Quote Link to comment https://forums.phpfreaks.com/topic/21420-number-problem/#findComment-95413 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.