我是新手,我遇到了一些麻烦。我有一个.txt文件,这个文件可以读取,但它强制所有字母都是大写字母,如何将其读取并显示.txt原样?
function rand_line($fileName, $maxLineLength = 4096) {
$handle = @fopen($fileName, "r");
if ($handle) {
$random_line = null;
$line = null;
$count = 0;
while (($line = fgets($handle, $maxLineLength)) !== false) {
$count++;
if(rand() % $count == 0) {
$random_line = $line;
}
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
fclose($handle);
return null;
} else {
fclose($handle);
}
return $random_line;
}
}
echo rand_line("textfile.txt");