Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.