PHP Quickly Finding Lines That Match Pattern – String Function

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

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.