I have a column of address data that has ordinals displayed like this:
3Rd Floor, Cumbrian House
Room 223, 2Nd Floor
when I would like them to be displayed like this instead:
3rd Floor, Cumbrian House
Room 223, 2nd Floor
I'm trying to make use of the preg_replace function to swap out a capitalised letter, that directly follows a number, with a lower case letter instead. (I admit this is my first time using the preg_replace function. I am however fine with preg_match and regular expressions).
So far I have:
$string = '3Rd Floor, Cumbrian House';
$ordinalregex = '/(^.*\d+)([A-Z])/';
$correctordinal = '$1'.strtolower('$2');
echo preg_replace($ordinalregex,$correctordinal,$string)."<br>";
But its not having the desired effect and outputs the line exactly as it first appeared.
Thanks