Mega Code Archive

 
Categories / Php / Strings
 

Efficiently finding lines that match a pattern

<? $fh = fopen('/path/to/your/file.txt', 'r') or die($php_errormsg); while (!feof($fh)) {     $line = fgets($fh);     if (preg_match($pattern, $line)) { $ora_books[ ] = $line; } } fclose($fh); ?>