What is the function preg_match_all() used for in PHP?

The function preg_match_all() in PHP is used to perform a global regular expression match on a string and return all matches. This function is particularly useful when you need to extract multiple occurrences of a pattern from a string.

<?php
$string = "The quick brown fox jumps over the lazy dog";
$pattern = '/\b\w{4}\b/';

preg_match_all($pattern, $string, $matches);

print_r($matches[0]);
?>