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