How can one ensure that preg_grep in PHP distinguishes between uppercase and lowercase letters when matching a pattern?
When using preg_grep in PHP, by default, it does not distinguish between uppercase and lowercase letters when matching a pattern. To ensure that preg_grep distinguishes between uppercase and lowercase letters, you can use the "i" modifier in the regular expression pattern. This modifier makes the pattern case-insensitive, allowing for a match regardless of letter case.
$pattern = '/example/i';
$array = ['Example', 'example', 'EXAMPLE'];
$matches = preg_grep($pattern, $array);
print_r($matches);