How can regular expressions be effectively used in PHP to filter and manipulate array elements based on specific patterns?

Regular expressions can be effectively used in PHP to filter and manipulate array elements based on specific patterns by using functions like preg_grep() and preg_replace(). Here is an example of how to filter an array based on a specific pattern using preg_grep():

<?php
$array = ['apple', 'banana', 'cherry', 'date', 'elderberry'];
$pattern = '/^b/';

$filteredArray = preg_grep($pattern, $array);

print_r($filteredArray);
?>