Quickly finding lines that match a pattern
<? $pattern = "/\bo'reilly\b/i"; // only O'Reilly books $ora_books = preg_grep($pattern, file('/path/to/your/file.txt')); ?>