piccounter.txt里的数字是327,为什么显示出来是4个图片?是不是结束符?如何解决
<?@$f=fopen("piccounter.txt", "r") or die("unable to open file!");
$num=fread($f, filesize("piccounter.txt"));
$num++;
fclose($f);
$fw=fopen("piccounter.txt", "w");
fwrite($fw, $num);
fclose($fw);
$fr=fopen("piccounter.txt", "r");
while (!feof($fr)) {
# code...
$char_array[]=fgetc($fr);
}
// echo count($char_array);
for ($i=0; $i <count($char_array) ; $i++) {
echo "<img src=\"$char_array[$i].jpg\" \>";
}
fclose($fr);
?>
<?
@$f=fopen("piccounter.txt", "r") or die("unable to open file!");
$num=fread($f, filesize("piccounter.txt"));
$num++;
fclose($f);
$fw=fopen("piccounter.txt", "w");
fwrite($fw, $num);
fclose($fw);
$fr=fopen("piccounter.txt", "r");
while (!feof($fr)) {
$char = fgetc($fr);
if(is_numeric($char)) $char_array[]=$char;
}
// echo count($char_array);
for ($i=0; $i <count($char_array) ; $i++) {
echo "<img src=\"$char_array[$i].jpg\" \>";
}
fclose($fr);
?>
用fgets比较好!
页:
[1]