Log 1956
07/08/2023 2023-08-07 6:19$fullName = #שם מלא#;
// Remove any leading or trailing white spaces from the full name
$fullName = trim($fullName);
// Count the number of words in the full name
$numWords = count(explode(” “, $fullName));
if ($numWords == 2) {
// If there are two words, assign the first word to firstName and second word to lastName
list($firstName, $lastName) = explode(” “, $fullName);
} elseif ($numWords == 3) {
// If there are three words, assign first two words to firstName and third word to lastName
list($firstName, $middleName, $lastName) = explode(” “, $fullName);
} elseif ($numWords >= 4) {
// If there are four or more words, assign first three words to firstName and fourth word onwards to lastName
list($firstName, $middleName1, $middleName2, …$lastNamesArray) = explode(” “, $fullName);
// Combine all last names into a single string separated by space
$lastName = implode(” “, $lastNamesArray);
}
return “First Name: ” . (isset($firstName) ? htmlentities($firstName) : “”) . “
“;
return “Last Name: ” . (isset($lastName) ? htmlentities($lastName) : “”);