<?php //CURRENT FILE NAME IS: files_in_dir.php //My working directory: /home/Zoltan/Dokumentumok $files = array_diff(scandir("files_test"), array('..', '.')); //Files scanned into $files from files_test folder echo getcwd()."\n"; echo "THINGS IN WORKING DIRECTORY"; //Files and folder listed in working directory foreach (scandir('.') as $file) echo $file . "\n"; echo "\n"; //Now I would like to find which line is in the CCCCCCCC pattern in each file in files_test directory foreach($files as $file) { echo $file."\n"; $search = "CCCCCCCC"; //BUT THE NEXT LINE DOES NOT WORK $lines = file($file); $line_number = false; while (list($key, $line) = each($lines) and !$line_number) { $line_number = (strpos($line, $search) !== FALSE) ? $key + 1 : $line_number; } //And print the line number echo "The line number is: ".$line_number."\n"; } ?>
$lines = file('"'.$file.'"');
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)