Advertisement
Guest User

Untitled

a guest
Apr 20th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.  
  3. // url = "www.domain.com/a/b/c?sort=price";
  4.  
  5. var_dump($_GET['query']);       // will return string(5) "a/b/c"
  6. var_dump($_SERVER['REQUEST_URI']);  // will return string(17) "/a/b/c?sort=price"
  7.  
  8. // htaccess will give you the value for query
  9. // now we parse the REQUEST_URI, to get the value for "sort" (if it exists)
  10.  
  11. $regex = '/\?sort=([^&]+)(?:&|$)/';
  12. $sort = preg_match($regex, $_SERVER['REQUEST_URI'], $regs) ? $regs[1] : ""; // $sort = 'price'
  13.  
  14. var_dump($sort);
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement