PHP copies each line to a different text file

Source: Internet
Author: User
PHP Text Bank

Well, honestly, this is a real problem.

So, I'm going to copy every line of text in Q.txt to 1.txt/2.txt/3.txt.

The Q.txt text format is as follows:
AJSG Blueprint Herbal Ajsv ajsm Apple machine ajsu? AJSC yellow fruit tree AJSJ Seven Stars Ladybug ajsu? AJT Blue AJTL Blue ajth spreading trouble AAGW respectfully better to obey

Requirements like the first, to divide him into two to write to 2.txt, all Chinese characters cannot have spaces behind.
Such as:
AJSG Blueprint AJSG Herb

Three words saved in 3.txt. Look like this.
Ajth Spread Trouble

Need to save to 2.txt one, 4.txt one
More than four words saved in 5.txt.
1.txt,2.txt, such as the format to be q.txt with the same, Chinese characters cannot have spaces behind
such as the 1.txt
A A-GE AA aaa work aaaa aaar? AAD-Type Aad aadk aadn te aadw qi Aadn


There is no big God help Ah, beg PHP solution, first thanked!


Reply to discussion (solution)

 
  4?5: $str _num; @file_put_contents ($fname. ". TXT ", $tap." ". Trim ($v)." \ r \ n ", file_append);}    }    

But this has a premise; need to see what format your Q.txt document is encoded in! I use UTF-8 here, also is the default your Q.txt document is UTF-8 encoded; come here; you should understand;

 
  4?5: $str _num; @file_put_contents ($fname. ". TXT ", $tap." ". Trim ($v)." \ r \ n ", file_append);}    }    

But this has a premise; need to see what format your Q.txt document is encoded in! I use UTF-8 here, also is the default your Q.txt document is UTF-8 encoded; come here; you should understand;
Thank you very much, problem solving! 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.