Jump to content

Spliting a page address


mhodgson

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.