Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // url = "www.domain.com/a/b/c?sort=price";
- var_dump($_GET['query']); // will return string(5) "a/b/c"
- var_dump($_SERVER['REQUEST_URI']); // will return string(17) "/a/b/c?sort=price"
- // htaccess will give you the value for query
- // now we parse the REQUEST_URI, to get the value for "sort" (if it exists)
- $regex = '/\?sort=([^&]+)(?:&|$)/';
- $sort = preg_match($regex, $_SERVER['REQUEST_URI'], $regs) ? $regs[1] : ""; // $sort = 'price'
- var_dump($sort);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement