Last active
June 14, 2017 00:13
-
-
Save jjsty1e/518c149bb75c3f47eeac89852444726b to your computer and use it in GitHub Desktop.
php大坑
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getReferer($link) | |
{ | |
$refMap = [ | |
'baidu' => '百度', | |
'sougou' => '搜狗', | |
'360' => '360', | |
'google' => '谷歌' | |
]; | |
foreach ($refMap as $key => $value) { | |
if (strpos($link, $key) !== false) { | |
return $value; | |
} | |
} | |
return '其他'; | |
} | |
echo getReferer('https://www.google.com/search?workd=%FD%##%#%E%D%D%D%D%D%D%'); | |
// so what will this output? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment