Jump to content

Splitting custom $_GET?


Chotor

Recommended Posts

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

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.