Php copies each line to other text files

Source: Internet
Author: User
Php copies each line to a PHP text line in another text file

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 Mo to ajsm Apple ajsu? Ajsc Yellow Fruit Tree ajsj seven-star ladybird ajsu? Ajt blue ajtl blue ajth spread to make it happen.

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 source 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
A engineer a GE aa aaa engineer aaaa engineer aaar? Aad type aad? Aadk release aadn release aadw release aadn release


Is there any great Help? please ask for a PHP solution. thank you!


Reply to discussion (solution)

 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;

 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;
Thank you very much for solving the problem! My text is UTF-8.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.