Template:Fname

From Robin's SM-201 Website
Revision as of 13:40, 10 November 2025 by Robinr78 (talk | contribs) (Created page with "<?php $fullName = {{{1}}}; // Split the full name into an array of words using space as the delimiter $nameParts = explode(" ", $fullName); // Check if there are at least two parts (first name and last name) if (count($nameParts) >= 2) { $firstName = $nameParts[0]; $lastName = $nameParts[1]; // Assuming the last name is the second part // Construct the desired format "lname, fname" $formattedName = $lastName . ", " . $firstName; echo $formattedName...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<?php $fullName = {{{1}}};

// Split the full name into an array of words using space as the delimiter $nameParts = explode(" ", $fullName);

// Check if there are at least two parts (first name and last name) if (count($nameParts) >= 2) {

   $firstName = $nameParts[0];
   $lastName = $nameParts[1]; // Assuming the last name is the second part
   // Construct the desired format "lname, fname"
   $formattedName = $lastName . ", " . $firstName;
   echo $formattedName; // Output: Doe, John

} else {

   echo "Invalid name format.";

} ?>