$conn =file_get_contents('2.txt'); //读取内容 $conn=mb_convert_encoding($conn,"UTF-8","GBK");//设置不乱码 $arr = explode('#',$conn);用#号把标题扩起来分割,('#'也可以用其它的代替) $result = array(); for($i = 1; $i < count($