random.php dosyası:
<?php
$file = "veri.txt";
$satirSayisi = getLines($file);

$satir = rand(0,$satirSayisi);
$i = 0;
$handle = fopen($file, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if($satir === $i){
echo $line;
}
$i++;
}

fclose($handle);
} else {
// error opening the file.
}

function getLines($file)
{
$f = fopen($file, 'rb');
$lines = 0;

while (!feof($f)) {
$lines += substr_count(fread($f, 8192), "\n");
}

fclose($f);

return $lines;
}
?>

<hr>
<button onClick="window.location.href=window.location.href">Yenile</button>
Örnek veri.txt dosyası:
1 ç
2 ö
3 Ş
4 Ü
5 Ğ
6 İ
7 ğ
8 ü
Verileri satır satır basar. O yüzden her satıra bir veri gelecek şekilde veri.txt dosyasını dizayn etmelisiniz.