- preg_match: documentation ( source)
<?php
$names = [
"Mr. Kiefer William Frederick Dempsey George Rufus Sutherland Sr.",
"Carolina Maria de Jesus",
"Kiefer William Frederick Dempsey George Rufus Sutherland Jr.",
"Mrs. Carolina Maria de Jesus"];
foreach($names as $name) {
preg_match('/(?:\w+\. )?(\w+).*?(\w+)(?: \w+\.)?$/', $name, $result);
echo $result[1] . ' ' . $result[2] . ' = ' . $result[1][0].$result[2][0] . PHP_EOL;
}