过路的牛牛们,帮小菜看下这段代码吧
想通过取得UA中的语言编码信息实现跳转,功能:如果UA包含非zh-CN的编码,跳转之,未设置语言信息的不跳转,
不是程序,自己查函数下午搞到现在还没实验成功,条件加循环就晕了,输出一堆no搞不定,大牛小牛帮帮忙,多谢啦!
<br />$ua = $_SERVER['HTTP_USER_AGENT']; <br />$lang = array("af-ZA","sq-AL","ar-DZ","ar-BH","ar-EG","ar-IQ","ar-JO","ar-KW","ar-LB","ar-LY","ar-MA","ar-OM","ar-QA","ar-SA","ar-SY","ar-TN","ar-AE","ar-YE","hy-AM","az Azeriaz-AZ-Cyrl","az-AZ-Latn Azeri","eu-ES","be-BY","bg-BG","ca-ES","zh-HK","zh-MO","zh-CN","zh-CHS","zh-SG","zh-TW","zh-CHT","hr-HR","cs-CZ","da-DK","div-MV","nl-BE","nl-NL","en-AU","en-BZ","en-CA","en-CB","en-IE","en-JM","en-NZ","en-PH","en-ZA","en-TT","en-GB","en-US","en-ZW","et-EE","fo-FO","fa-IR","fi-FI","fr-BE","fr-CA","fr-FR","fr-LU","fr-MC","fr-CH","gl-ES","ka-GE","de-AT","de-DE","de-LI","de-LU","de-CH","el-GR","gu-IN","he-IL","hi-IN","hu-HU","is-IS","id-ID","it-IT","it-CH","ja-JP","kn-IN","kk-KZ","kok-IN","ko-KR","ky-KZ","lv-LV","lt-LT","mk-MK","ms-BN","ms-MY","mr-IN","mn-MN","nb-NO","nn-NO","pl-PL","pt-BR","pt-PT","pa-IN","ro-RO","ru-RU","sa-IN","sr-SP-Cyrl","sr-SP-Latn","sk-SK","sl-SI","es-AR","es-BO","es-CL","es-CO","es-CR","es-DO","es-EC","es-SV","es-GT","es-HN","es-MX","es-NI","es-PA","es-PY","es-PE","es-PR","es-ES","es-UY","es-VE","sw-KE","sv-FI","sv-SE","syr-SY","ta-IN","tt-RU","te-IN","th-TH","tr-TR","uk-UA","ur-PK","uz-UZ-Cyrl","uz-UZ-Latn","vi-VN");<br /><br />for($i=0;$i<136;$i++){<br />if(is_numeric(stripos($ua,$lang[$i])) == false){<br /> echo "no";<br />}else{<br /> echo "yes";<br />}<br />}<br /><br />
<br />if (preg_match("/zh/i", substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 4))) {<br /> echo "不跳转";<br />}else {<br /> echo "跳转";<br />}<br />