PHP assigns a txt file to the array _ PHP Tutorial

Source: Internet
Author: User
PHP assigns a txt file to an array. Dependencies); print_r (there are many methods in php to convert text files into arrays. the most direct method is the file function.

For example

The code is as follows:

$ Array = file('bKjia.c0m.txt ');

Print_r ($ array );

In this way, the array is output directly. you can try it.


Instance 2

Another friend said that file_get_contents () was first saved to the variable and then explode was used to split the nr. this is also a way, which is much less efficient. I recommend the first method.

Example code $ array = file('111cn.net.txt '); print_r (...

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.