How can PHP developers ensure that their regular expressions are case-insensitive when searching for specific patterns?

To ensure that regular expressions are case-insensitive when searching for specific patterns in PHP, developers can use the "i" modifier in the regex pattern. This modifier tells PHP to perform a case-insensitive search, meaning it will match patterns regardless of the casing of the letters.

$pattern = '/example/i';
$string = 'This is an Example string';
if (preg_match($pattern, $string)) {
    echo 'Pattern found!';
} else {
    echo 'Pattern not found.';
}