How can the use of regular expressions in PHP be optimized for efficiency when extracting multiple occurrences of a pattern?

When extracting multiple occurrences of a pattern using regular expressions in PHP, it is more efficient to use the `preg_match_all()` function instead of `preg_match()`. This function will return all matches of the pattern in the input string, rather than just the first match. By using `preg_match_all()`, you can avoid unnecessary iterations and improve the efficiency of your code.

$input = "The quick brown fox jumps over the lazy dog";
$pattern = "/\b\w{4}\b/"; // Match 4-letter words

if (preg_match_all($pattern, $input, $matches)) {
    foreach ($matches[0] as $match) {
        echo $match . "\n";
    }
}