Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created July 11, 2011 06:51
Show Gist options
  • Save ctrl-freak/1075396 to your computer and use it in GitHub Desktop.
Save ctrl-freak/1075396 to your computer and use it in GitHub Desktop.
Nice Filter Terms in PHP
<?
if ($url_parts[1]!='')
{
$args = array();
for($i=0; $i<count($url_parts);$i++) {
switch($url_parts[$i]) {
case 'page':
{
$args['page']=$url_parts[$i+1];
break
}
case 'from':
{
$args['from']=$url_parts[$i+1];
break;
}
case 'over':
{
$args['over']=$url_parts[$i+1];
break
}
case 'under':
{
$args['under']=$url_parts[$i+1];
break;
}
case 'near':
{
$args['near']=$url_parts[$i+1];
break;
}
}
}
search($args);
}
?>
@ctrl-freak
Copy link
Author

Could probably make this cleaner with an array of terms, and assign with $args[$term].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment