strong-storm Posted February 19, 2005 Report Share Posted February 19, 2005 Man ir txt faili, kuros glabaajas ip adreses. Faila nosaukums ir konkrētas dienas datums. Kā iespējams meklēt visos failos konkrēto ip, pēc tam izvadīt uz ekrāna failu nosaukumus, kuros atrodas šī ip? Link to comment Share on other sites More sharing options...
orion Posted February 19, 2005 Report Share Posted February 19, 2005 Nolisto direktoriju ar failiem --> paarlasi katru failu --> ielasi deriigos failu nosaukumus masiivaa --> izvadi, kur vajadziigs. Tas arii viss. Link to comment Share on other sites More sharing options...
loderis Posted February 19, 2005 Report Share Posted February 19, 2005 (edited) $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 February 19, 2005 by loderis Link to comment Share on other sites More sharing options...
strong-storm Posted February 19, 2005 Author Report Share Posted February 19, 2005 saka, ka kjuuda $faili[]=$f; direktoriju defineeju $d=opendir("/caunter"); Link to comment Share on other sites More sharing options...
loderis Posted February 19, 2005 Report Share Posted February 19, 2005 bišk pielaboju (iesācēju kļudas). P.S var jau uzreiz uz ekrāna drukāt failus: $faili[ ]=$f; vietā raksti echo $f; un viss Link to comment Share on other sites More sharing options...
strong-storm Posted February 20, 2005 Author Report Share Posted February 20, 2005 paldies!!! viss sanāca! Link to comment Share on other sites More sharing options...
Recommended Posts