Blogger Information
Blog 6
fans 0
comment 0
visits 5225
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
读取文件
Pythonxzm
Original
680 people have browsed it
<?php
    $filename = 'test.txt';


   //打开这个文件,将文件内容赋值给$filestring
   $filestring = file_get_contents($filename);

   //因为每一行有一个回车即\n,我用\n来把这个字符串切割成数组
   $filearray = explode("\n", $filestring);

   //把切割成的数组,下标赋值给$key,值赋值给$val,每次循环将$key加1。
   while (list($key, $val) = each($filearray)) {
       ++$key;
       //用的单引号,单引号不解释变量进行了拼接而已
       print 'Line' . $key .':'.  $val.'<br />';
   }
?>

QQ截图20170924012753.pngQQ截图20170923223327.png

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post