Home > Backend Development > PHP Tutorial > PHP assigns the value of the txt file to the array_PHP tutorial

PHP assigns the value of the txt file to the array_PHP tutorial

WBOY
Release: 2016-07-13 16:55:22
Original
832 people have browsed it

There are many ways to convert text files into arrays in php. The most direct way is to use the file function

such as

The code is as follows
 代码如下 复制代码

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

print_r( $array );

Copy code

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

print_r( $array );

This will directly output the array. Friends can try it

Example 2Some friends said that file_get_contents() first saves it to a variable and then uses explode to split it with nr. This is also a way, but the efficiency is much worse. I recommend the first method. http://www.bkjia.com/PHPjc/631678.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/631678.html
TechArticleThere are many ways to convert text files into arrays in php. The most direct way we can use file The function code is as follows. Copy the code $array = file('111cn.net.txt'); print_r(...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template