mhodgson Posted September 27, 2007 Share Posted September 27, 2007 I'm sure this is a fairly 'simple' one but I've confused myself trying to do it. If I have a page address e.g. "subjects.php?namefirst=Fname&sel_year=Y5&sel_class=all" can I then grab it and split it at the ? so that I can pass everything after the ? 'namefirst=Fname&sel_year=Y5&sel_class=all' onto another page? Link to comment https://forums.phpfreaks.com/topic/70917-spliting-a-page-address/ Share on other sites More sharing options...
jaymc Posted September 27, 2007 Share Posted September 27, 2007 explode(); $url = $_SERVER['HTTP_HOST']; $spliturl = explode("?", $url); echo $spliturl[1]; That will contain everything after the ? in your full URL Link to comment https://forums.phpfreaks.com/topic/70917-spliting-a-page-address/#findComment-356503 Share on other sites More sharing options...
mhodgson Posted September 28, 2007 Author Share Posted September 28, 2007 Didn't work. $url = $_SERVER['HTTP_HOST']; only gave the web server (localhost in my case). However played around with the $_server[] bit tried $_SERVER['PHP_SELF'] but that left out the stuff after the ?. After a little searching found this $_SERVER['REQUEST_URI']; Added it into the code and it seems to give me what I want. $url = $_SERVER['REQUEST_URI']; $spliturl = explode("?", $url); echo $spliturl[1]; Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/70917-spliting-a-page-address/#findComment-357135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.