<?php
$handle = @fopen("text_alani.txt", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?> Texten Rastgele veri cekmek
3
●804
- 30-11-2009, 04:03:40arkadaşlar aşağıdaki kod text dosyasından veri çekme kodu peki ben bu textlere 1.2.3.4.5........ seklınde ad verip nasıl rastgele veri çekebilirim ?
- 30-11-2009, 04:37:08Üyeliği durduruldu
<?php $dosyalar = array( '1.txt', '2.txt', '3.txt', '4.txt', '5.txt' ); $handle = @fopen($dosyalar[array_rand($dosyalar)], "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> - 30-11-2009, 04:53:16Eline sağlık hocam bende yazdım tam denıyordum cevap verdiniz saolun...
buda benımkı çalıştı bizzat
<?php $toplam = "10"; $dosya_uzantisi = ".txt"; $dosya = "t"; $rastgele = mt_rand($ilk, $toplam); $dosya_adi = $rastgele . $dosya_uzantisi; $handle = @fopen("$dosya/$dosya_adi", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> - 30-11-2009, 05:01:37Üyeliği durduruldurica ederim, ayrıca yazdıgınız kodlar ile aynı işi yapacak kısa hali;
echo file_get_contents(rand(1, 10) . '.txt');
