The code below checks for GET params. There are two selects on the page which filter a list by type and age group.
I'm looking for a way to refactor the conditional which test the type/age combinations. Is there a more clear/concise way to write it?
if ( isset($_REQUEST['type']) || isset($_REQUEST['age']) )
{
// we need to do something
$type = ( $_REQUEST['type'] == 'all' ? false : (int)($_REQUEST['type']) );
$age = ( $_REQUEST['age'] == 'all' ? false : (int)($_REQUEST['age']) );
// test the possible type/age combinations
if ($type && $age)
{
$cats = $type . "," . $age;
}
elseif ($type)
{
$cats = $type;
}
elseif ($age)
{
$cats = $age;
}
else
{
$cats = false;
}
// do stuff with $cats;
}