$line_body = array('张三','李四','王五'); $line_body = array_map(function ($element){return iconv('UTF-8','GBK',$element);}, $line_body); //汉字转码 $body[] = implode(" ", $line_body)." "; file_put_contents('./test_gbk.txt', $body);