What is the purpose and syntax of the preg_match_all function in PHP?

The preg_match_all function in PHP is used to perform a global regular expression match on a string and return all matches. This function allows you to extract multiple occurrences of a pattern from a string. The syntax for preg_match_all is preg_match_all($pattern, $subject, $matches), where $pattern is the regular expression pattern to search for, $subject is the string to search within, and $matches is an array that will be filled with the matched patterns.

$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]);