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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.