Home >Backend Development >PHP Tutorial > 新手请问个PHP查找TXT内容并输出的有关问题
新手请教个PHP查找TXT内容并输出的问题!
新手请教个PHP查找TXT内容并输出的问题!
1.TXT里的内容如下:
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->101010100=北京 101010200=海淀 101010300=朝阳 101010400=顺义 101010500=怀柔 101010600=通州 101010700=昌平 101010800=延庆 101010900=丰台 101011000=石景山 101011100=大兴 101011200=房山 101011300=密云 101011400=门头沟 101011500=平谷 101011600=八达岭
$city=$_REQUEST["city"]; $city=iconv("utf-8","gb2312",$city); if ($city) { $fp=fopen("data.txt","r"); while (!feof($fp)) { $buffer = fgets($fp); list($code,$area)=explode("=",$buffer); if (trim($area)==$city) { echo $code; } } fclose($fp); } ?> <br><font color="#e78608">------解决方案--------------------</font><br>