How can the #U modifier affect the behavior of preg_match_all in PHP?

When using the preg_match_all function in PHP, the #U modifier can affect the behavior by making the matching process ungreedy, meaning it will match as little as possible instead of as much as possible. This can be useful when you want to match the smallest possible substring within a larger string. To use the #U modifier, simply append it to the end of your regular expression pattern.

$string = "Hello World";
$pattern = '/\b\w+#U/';
preg_match_all($pattern, $string, $matches);
print_r($matches[0]);