新手请教个PHP查找TXT内容并输出的问题!
新手请教个PHP查找TXT内容并输出的问题!
1.TXT里的内容如下:
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);}?>
[解决办法]