怎样将txt文件当做小型数据库,并用php读取txt文件,分别读取出来
id.txt的内容如下
29384733
4895734
23490879
....
index.php的内容如下
$file = 'id.txt';
$content = file_get_contents($file);
$array = explode("\r\n", $content);
for($i=0; $i<count($array); $i++)
{
echo '$array[$i]';
}
==========================
以上是目前的情况,如果在id.txt中再曾加一个字段,怎么样改写index.php代码,并全部都读出来?
29384733----2013-12-29 19:57:20
4895734----2013-12-29 19:58:13
23490879----2013-12-29 19:59:02
...
附个运行图:(左上方为代码,右上方为用得输入数据,下方为输出结果),如果要添加多个字段的话,同理可以实现的,只要保证所使用的分隔符不会出现在所需要输出的数据中就行。