<?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 />';
}
?>
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!