What potential issues can arise when using preg_match_all with regular expressions in PHP?

One potential issue when using preg_match_all with regular expressions in PHP is that it may return an empty result if the pattern is not matched in the input string. To solve this, you can check if preg_match_all returns false and handle this case accordingly.

// Example code snippet to handle empty result from preg_match_all

$input_string = "Hello World";
$pattern = "/foo/";

if (preg_match_all($pattern, $input_string, $matches) === false) {
    echo "Pattern not found in input string";
} else {
    // Process $matches array
}