Chotor Posted July 22, 2008 Share Posted July 22, 2008 I need to split a $_GET into its separate fields. $_GET can contain the following fields: type product size year country (and their respective values) It can contain any of these (or all of them). For example getXML?type=1,2,7/size=2/country=5 I want ONLY the element WITH values For example: type={1,2,7} size={2} country={5} year <- not set product <- not set Because later in the code I have a check if(isset($country) && $country!=null) {...} Currently this evaluates to TRUE with my way of $_GET. I DON'T want this to happen. That's why I'm looking for a good method of splitting the $_GET into only the applicable fields. This is my current code: $countries = split(",", $_GET['country']); $years = split(",", $_GET{'year'}); Link to comment https://forums.phpfreaks.com/topic/115984-splitting-custom-_get/ Share on other sites More sharing options...
huesped214 Posted July 22, 2008 Share Posted July 22, 2008 if (isset($_GET['country'])) { $countries = split(",", $_GET['country']); } if(isset($country) && $country!=null) {...} you answered yourself Link to comment https://forums.phpfreaks.com/topic/115984-splitting-custom-_get/#findComment-596329 Share on other sites More sharing options...
Chotor Posted July 22, 2008 Author Share Posted July 22, 2008 Haha! You're right. Thanks for pointing that out. I was looking for a more elegant solution. Perhaps something involving implode/explode. But this will do for now. Link to comment https://forums.phpfreaks.com/topic/115984-splitting-custom-_get/#findComment-596445 Share on other sites More sharing options...
MasterACE14 Posted July 22, 2008 Share Posted July 22, 2008 splits fine for this Link to comment https://forums.phpfreaks.com/topic/115984-splitting-custom-_get/#findComment-596459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.