Burhan KARADERE Kişisel Blog - Bilgisayar IT Haber - Programlama - Donanım

Hızlı Erişim

Arşiv

Php ile Dosya Okuma (txt text)

Php ile dosya Okuma (txt text)  Aşağıdaki örneğimizde  root dosyadaki dosya.txt içinin okunması ile ilgili örnek mevcuttur. Fopen fonksiyonu ile dosya açılarak printe fonksiyonu ile satır satır yazdırıyoruz.

<?

/*
$dosya_adi=”dosya.txt”;
if ($dosya=fopen(“$dosya_adi”,’r'))
{
$i=0;
while ($i <= 5) {
$i++;
$satir=fgets($dosya,1024);
print “”.$satir.”<br>”;

}
}
else
print “Dosya açılamadı: “.$dosya_adi;

*/
$dosya = file(“dosya.txt”);
foreach ($dosya as $satsayisi => $satir)
{
}
$hedefsatir = $satsayisi  – 5;

//print $hedefsatir ;

foreach ($dosya as $satsayisi => $satir)
{
if ($hedefsatir==$satsayisi){

print $satir;

}

}
/*
$str = “Hello#world!”;
$bol = spliti(‘#’,$str);

print $bol[1];

*/

?>

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>