Simple, you change your regex pattern and remove the ^
which specifies it has to be the start of the string. Case insensitivity can be achieved with the i
modifier.
$matching_letters = 'ri';
$array = preg_grep("/{$matching_letters}/i", $array);
// Marian
Demo: https://eval.in/151916
Edit: you can also remove the .*
(s) in this case and just match the letters.
For future reference, Regex101.com and PHPLiveRegex.com will do you wonders for learning regex.