Bir dosyadan belirli bir hat almak için çalışıyor.

0 Cevap php

Ben küçük bir sorun var. Ben PHP kullanarak bir metin dosyasından bir satır almak gerekiyor. İşte metin dosyasının bir örneği:

hello 2010-10-25
hello 2010-10-26
hello 2010-10-27
hello 2010-10-28
hello 2010-10-29
hello 2010-10-30
hello 2010-10-31

Ve "2010/10/26" içeren bir satırı dışında ayırdığınız için benim kod şudur:

<?php
 $datefile = fopen('file.txt', 'r') or exit("Unable to open file.txt");

 while(!feof($datefile))
 {
  $date = "2010-10-26";
  $string = fgets($datefile);
  if(strpos($string, $date)==true)
  {
   echo fgets($datefile);
  }

 }
 fclose($datefile);
?>

Bunun yerine hat "merhaba 2010-10-26" yazdırmanın o "merhaba 2010-10-27" ne oluyor hiçbir fikrim yok, lütfen yardım yazdırır.

0 Cevap