test.txt的内容是
小明----五岁----15年11月27日
张三----六岁----15年11月27日
李四----七岁----15年11月27日
想要取出的是小明 五岁 时间这样一个个表格显示出来
<?php
$hello = explode('----',file_get_contents('test.txt'));
{
echo 'a'.$hello[0].'b'.$hello[1].'c'.$hello[2];
}
?>
输出hello数组3把张三都输出来了,求解决
第1个回答 推荐于2016-03-26
<?php
$file = fopen("data/test.txt","r");
echo("<table>");
while(! feof($file))
{
$hello = explode('----',fgets($file));
echo("<tr> <td>".$hello[0]."</td><td>".$hello[1]."</td><td>".$hello[2]."</td><tr>");
}
fclose($file);
?>本回答被提问者采纳
$file = fopen("data/test.txt","r");
echo("<table>");
while(! feof($file))
{
$hello = explode('----',fgets($file));
echo("<tr> <td>".$hello[0]."</td><td>".$hello[1]."</td><td>".$hello[2]."</td><tr>");
}
fclose($file);
?>本回答被提问者采纳