1) { $lastname = array_pop($names); $test = $names[count($names) - 1]; $lastnamePrefixes = ['da', 'de', 'der', 'van', 'von']; if (in_array($test, $lastnamePrefixes)) { if ($test == 'der' && $names[count($names) - 2] == 'van' || $names[count($names) - 2] == 'von' ) { $lastname = implode(' ', array_splice($names, -2)) . ' ' . $lastname; } else { array_pop($names); $lastname = $test . ' ' . $lastname; } } $firstnames = implode(" ", $names); return ['firstnames' => $firstnames, 'lastname' => $lastname]; } return $string; } /** * Checks if a string ands with another string. * @param $haystack * @param $needle * @return bool */ public static function endsWith($haystack, $needle): bool { return substr_compare($haystack, $needle, -strlen($needle)) === 0; } /** * Checks if a string starts with another string. * @param $haystack * @param $needle * @return bool */ public static function startsWith($haystack, $needle): bool { return substr_compare($haystack, $needle, 0, strlen($needle)) === 0; } }