Jump to content
php.lv forumi

find in txt files


strong-storm

Recommended Posts

$dir="./counter/";
$d=opendir($dir);
//lasam direktoriju
while(($f=readdir($d)) != false) {
//veram valjaa failu, faila paplashinaajums ir "txt"
if((substr($f,-3,3)=="txt")) {
$handle = file($dir.$f);
//lasam failu pa rindinjaam
foreach($handle as $line){
//ja taa satur $ip tad pieraktam klaat $failu masiivam shii faila nosaukumu un veram ciet failu.
if (trim($line)==$ip) {
 $faili[ ]=$f;
 break;
 }

}
}

}
closedir($d);
//masivs $faili saturees failu nosaukumus kuros tika atrasts $ip

Edited by loderis
Link to comment
Share on other sites

×
×
  • Create New...