Home > php教程 > php手册 > PHP把txt文件的赋值给数组

PHP把txt文件的赋值给数组

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-25 16:56:31
Original
1415 people have browsed it
在php中有很多方法把文本文件把转换成数组的方法,最直接的我们可以用到file函数

 代码如下 复制代码

$array = file('phprm.com.txt');

print_r( $array );

这样就直接输出的数组哦,朋友可以试一下


实例二

还有朋友说有file_get_contents()先保存到变量再利用explode以nr进行分切,这样也是办法,这样在效率就要差很多,我推荐第一种方法。



本文地址:

转载随意,但请附上文章地址:-)

Related labels:
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
Latest Issues
explode function splits an array
From 1970-01-01 08:00:00
0
0
0
Explode array based on value
From 1970-01-01 08:00:00
0
0
0
Resize image before upload in Laravel 5.8
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template