I’d love to know how to get the word “author” from a url as in
www.example.com/?author=seth-godin
I’m using wordpress – so I can always know that the URL will look exactly like that. I’ve used Regex to get everything after the “/” but that’s too much. Here’s that code.
preg_match("/[^/]+$/",$_SERVER['REQUEST_URI'], $matches);
$author = $matches[0]; // test
Any help?
$_SERVER['QUERY_STRING']
should be able to get the ‘author=seth-godin’ part, then just explode at & (if multiple parameters), or at = and use the first value i.e.explode('=',$_SERVER['QUERY_STRING']
. zero index of that array = author. (similar to below)array_keys($_GET) will return array(0=>’author’);