Heim >Backend-Entwicklung >PHP-Tutorial >php把每行复制到其他文本文件里
PHP 文本 行
好吧,说实话这个实在是麻烦ajsg 蓝本 草本ajsv 莫要ajsm 苹果机ajsu ?ajsc 黄果树ajsj 七星瓢虫ajsu ?ajt 蓝ajtl 蓝ajth 蔓延 惹是生非aagw 恭敬不如从命
ajsg 蓝本ajsg 草本
ajth 蔓延 惹是生非
a 工a 戈aa 式aaa 工aaaa 工aaar ?aad 式aad ?aadk 匿aadn 慝aadw 萁aadn 葚
<?php$handle = @fopen("q.txt", "r");if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $data=explode(' ',trim($buffer)); $tap=trim(array_shift($data)); foreach($data as $v){ $encode = 'UTF-8'; $str_num = mb_strlen(trim($v),$encode); $fname=$str_num>4?5:$str_num; @file_put_contents($fname.".txt",$tap." ".trim($v)."\r\n",FILE_APPEND); } } fclose($handle);}?>
<?php$handle = @fopen("q.txt", "r");if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $data=explode(' ',trim($buffer)); $tap=trim(array_shift($data)); foreach($data as $v){ $encode = 'UTF-8'; $str_num = mb_strlen(trim($v),$encode); $fname=$str_num>4?5:$str_num; @file_put_contents($fname.".txt",$tap." ".trim($v)."\r\n",FILE_APPEND); } } fclose($handle);}?>