Hello there!
I've been trying to figure out a solution to this problem below for quite som time now, with no success. I would be glad if some of you could help me with this (if it's even possible).
Background,
I have two arrays. One with 'search' regexps and another array with its corresponding 'replace' strings (I have slimmed the arrays and only shown the one that I can't find a solution for).
What I'd like to do, is to get the text string 'mr. west' ($string) in proper case, using the preg_replace function seen below.
There is of course no problem with getting 'mr. '|'mr.' to become 'Mr. '|Mr.' since it's static, however, for the second backreference (with different surnames), I have no clue on how to complete it.
I'd appreciate all help on this! Thank you very much for your time!
$string = "mr. west";
$search = array (
"/mr.( )?(.)/",
);
$replace = array (
"Mr.\\1\\2",
);
echo preg_replace($search, $replace, $string);
Have a good one!
Best regards,
Stephan