Efficiently finding lines that match a pattern : preg_match « String « PHP
- PHP
- String
- preg_match
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);
?>
Related examples in the same category