<?php
$content = $_POST['file'];
$arr = preg_split('/[;\r\n]+/s',$content); //将文本分行转换成数组
$new = array_chunk($arr,40); //分割成小数组
$i = 1;
foreach ($new as $item) {
file_put_contents($i.'.txt',implode("\n",$item));
$i++;
}
echo "ok";
<?php
$content = $_POST['file'];
$arr = preg_split('/[;\r\n]+/s',$content); //将文本分行转换成数组
$new = array_chunk($arr,40); //分割成小数组
$i = 1;
foreach ($new as $item) {
file_put_contents($i.'.txt',implode("\n",$item));
$i++;
}
echo "ok";
本文标题:php分割大文本成多个txt文件
本文链接:https://www.haomeiwen.com/subject/hpninftx.html
网友评论