How can case insensitivity be implemented in a regular expression pattern in PHP?

When using regular expressions in PHP, you can implement case insensitivity by using the 'i' modifier at the end of the pattern. This modifier tells PHP to perform a case-insensitive match when applying the regular expression.

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