August 30th, 2010, 06:35 AM
-
Sub string for q
hello,
I getting url string, for example:
http://www.google.com/#hl=en&source=hp&q=php&aq=f&aqi=g10&aql=&oq=&gs_rfai=&pbx=1&fp=93c3c78db929eee0
How can I get into variable the string between "&q" and "&" (in this example it's: "php"
?
Thank you in advance,
Roi
August 30th, 2010, 06:57 AM
-
Ok, someone helped me.
Here it is if someone else gonna need it:
PHP Code:
$url = 'http://www.google.com/#hl=en&source=hp&q=php&aq=f&aqi=g10&aql=&oq=&gs_rfai=&pbx=1&fp=93c3c78db929eee0';
preg_match("/\&q=(.*?)\&/", $url, $matches);
$str = $matches[1];
August 30th, 2010, 08:00 AM
-
Avoid regular expressions when there are existing functions that can do what you need.