strong-storm Posted February 19, 2005 Report 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?
orion Posted February 19, 2005 Report Posted February 19, 2005 Nolisto direktoriju ar failiem --> paarlasi katru failu --> ielasi deriigos failu nosaukumus masiivaa --> izvadi, kur vajadziigs. Tas arii viss.
loderis Posted February 19, 2005 Report 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
strong-storm Posted February 19, 2005 Author Report Posted February 19, 2005 saka, ka kjuuda $faili[]=$f; direktoriju defineeju $d=opendir("/caunter");
loderis Posted February 19, 2005 Report 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
Recommended Posts