damiantaylor Posted March 21, 2010 Share Posted March 21, 2010 Hi, I want to be able to test if a particular price range was passed in the URL. The URL I'm passing is www.myurl.com?Price_Range=10-20&Price_Range=20-30 I've tried using something like this if(isset($_GET['Price_Range']['10-20'])) echo 'found it'; But it didn't work. Is there a way I can check for a value passed in the URL given the key is 'Price_Range'? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/ Share on other sites More sharing options...
slurpee Posted March 21, 2010 Share Posted March 21, 2010 URL should be: www.myurl.com?Price_Range=10-20 list($low,$high) = preg_split(":-:",$_GET[Price_Range]); Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029694 Share on other sites More sharing options...
damiantaylor Posted March 21, 2010 Author Share Posted March 21, 2010 Thanks slurpee, but I want to be able to pass in more than one price range because the ranges could be 10-20, 50-60. Can I do something like that? Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029696 Share on other sites More sharing options...
teamatomic Posted March 21, 2010 Share Posted March 21, 2010 You can't pass the same name more than once or you will be returned only the last value, you can however pass an array: page.php?array[0]=1-10&array[1]=11-20 HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029701 Share on other sites More sharing options...
greatstar00 Posted March 21, 2010 Share Posted March 21, 2010 or page.php?price_range[]=1-10&price_range[]=11-20 Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029702 Share on other sites More sharing options...
damiantaylor Posted March 21, 2010 Author Share Posted March 21, 2010 Thanks for your help guys! I've now got page.php?price_range[]=1-10&price_range[]=21-30 in my URL Can I now use in_array or something to see if 21-30 was passed in price_range? Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029711 Share on other sites More sharing options...
slurpee Posted March 21, 2010 Share Posted March 21, 2010 Thanks for your help guys! I've now got page.php?price_range[]=1-10&price_range[]=21-30 in my URL Can I now use in_array or something to see if 21-30 was passed in price_range? Yep: if(in_array("21-30",$_GET[price_range])) { // Do whatever here } Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029715 Share on other sites More sharing options...
damiantaylor Posted March 21, 2010 Author Share Posted March 21, 2010 Perfect! Thanks everyone for your help Quote Link to comment https://forums.phpfreaks.com/topic/196038-get-values-from-url/#findComment-1029717 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.