Jump to content

[SOLVED] Find q string in a URL


The Little Guy

Recommended Posts

I need to find text between:

 

q= and an & from a url passed to a variable. but... sometimes there is no ampersand, because the q= is at the end of the URL, so How can I find the q string?

 

if(preg_match("~q=(.+?)&~",$ref,$matches)){
$search = $matches[1];
}

 

my code receives this string as ONE string NOT multiple GET variables

Link to comment
https://forums.phpfreaks.com/topic/124712-solved-find-q-string-in-a-url/
Share on other sites

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.