How can one modify a regular expression pattern to capture multiple occurrences of a specific pattern in PHP?

To capture multiple occurrences of a specific pattern in PHP using regular expressions, you can modify the pattern by adding the quantifier "+", which matches one or more occurrences of the preceding element. This allows you to capture all instances of the pattern within the input string.

$input = "The cat and the dog are playing in the garden.";
$pattern = '/the \w+/i'; // Match "the" followed by a word character
preg_match_all($pattern, $input, $matches);

print_r($matches[0]); // Output: Array ( [0] => the cat [1] => the dog )