The text format of examples/2.txt/ 3.txtq.txt is as follows: ajsg & nbsp; blueprint & nbsp; herbal ajsv & nbsp; Mo Yao ajsm & nbsp; macOS ajsu & nbsp; php copies each line to other text files
Okay. To be honest, this is really troublesome.
In this case, copy the number of tokens in q.txt to 1.txt/2.txt/ 3.txt.
The q.txt text format is as follows:
Ajsg blueprint herb
Ajsv Moyao
Ajsm Apple
Ajsu logs
Ajsc Huangguoshu
Ajsj Dipper Ladybug
Ajsu logs
Ajt Blue
Ajtl Blue
Ajth spread
Aagw is respectful
For the first character, separate the two characters and write them into 2.txt. no spaces are left behind all Chinese characters.
For example:
Ajsg blueprint
Ajsg herb
The three characters are stored in 3.txt. Like This
Ajth spread
The token is saved to 2.txt and 4.txt.
Four characters are stored in 5.txt.
The format of 1.txt,2.txtmust be the same as that of q.txt.
For example, 1.txt
Work
A GE
Aa type
Aaa worker
Aaaa worker
Aaar labels
Aad type
Aad connector
Aadk plugin
Aadn subnet
Aadw release
Aadn subnet
Is there any great Help? please ask for a PHP solution. thank you! PHP text lines are shared:
------ Solution --------------------
$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);
}
?>
Let's look at the encoding format of your q.txt document! I am using or above your q.txt document is UTF-8 code; come here; you should understand;