-3
我在閱讀文本文件信息時遇到了一些困難。是否可以使用php並一次獲取一行,並將該行與一個變量一次比較一個字符?每當我添加字符搜索算法,它都會搞砸。或做文件讀取只能做滿檔/線/字符 例如:php從文件讀取和操作數據
$file=fopen("text/dialogue.txt","r") or exit("unable to open dialogue file");
if($file == true) {
echo "File is open";
fgets($file);
$c = "";
while(!feof($file)) {
$line = fgets($file)
while($temp = fgetc($line)) {
$c = $c . $temp;
//if statement and comparrison
}
}
} else {
echo "File not open";
}
fclose($file);
你在這裏失蹤的分號:$行=與fgets($文件) – user4035
FGE tc函數需要傳遞一個處理函數,而不是像字符串一樣傳遞:fgetc($ line)。 http://php.net/manual/en/function.fgetc.php – user4035