Regular expression to detect the search engine and search words

时光怂恿深爱的人放手 提交于 2019-12-03 21:44:44

This blog entry about extracting keywords from the referrer seems like it is a good match for solving your problem.

I found it using this search for 'extract query string from google referer url'. The search seems to have a number of helpful hits... I just did a sweep of the first few.

I would use parse_url to parse the URL and parse_str to parse the URL query.

$url = 'http://www.google.com/search?q=blabla&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu%3Aen-GB%3Aofficial&client=firefox-a';
$parts = parse_url($url);
if (isset($parts['query'])) {
    parse_str($parts['query'], $parts['query']);
}
var_dump($parts);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!