Please see my code below.
this returns John Doe L. R T
I want it to return John Doe L. R. T.
$string = "John Doe L R T";
$matches = null;
preg_match('/\b\s[a-zA-z]{1}\b/i', $string, $matches);
foreach ($matches as $match)
{
$string = str_replace($match, $match.'.',$string);
}
echo $string;