我有問題。我有一個文本文件,我已經安裝在PHP中,我想分開350個單詞並將它們保存爲文本文件,如1.txt 2.txt 3.txt ...我該怎麼做?用php劃分文本
我試過,但沒有奏效:
$text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam
nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et.";
$word = explode(" ", $text);
$count = count($word);
$limit = 40;
if($count <= $limit) {
$cut = $count * 50/100;
} else {
$cut = $limit;
}
for($i = 0; $i <= $cut; $i++) {
$text1= $word[$i] . ' ';
echo $text1;
}
所以你的文件包含一行一行或類似段落的值? –
我的文件包含類似 的值,並且不,這不是我的作業:) – nymfer
所以這不好: - https://eval.in/841266 –