问题描述
<?PHP
$fp=fopen("../resources/client.txt","r");
$trouve=0;
$cnt=0;
while(!feof($fp)){
$i=0;
$cnt++;
echo "<br>";
$ligne=fgets($fp);
$row=explode("|",$ligne);
while($i<=2){
echo $row[$i]."|";
$i++;}
}
fclose($fp); ?>
这个问题有简单的解决方案吗? 提前谢谢大家。
解决方法
在空行中,您既没有 $row[1]
也没有 $row[2]
<?php
$fp=fopen("../resources/client.txt","r");
$trouve=0;
$cnt=0;
while(!feof($fp)){
$i=0;
$cnt++;
echo "<br>";
$ligne=fgets($fp);
$row=explode("|",$ligne);
if (isset($row[$i])) {
while($i<=2){
echo $row[$i]."|";
$i++;
}
}
}
fclose($fp); ?>