• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Split Name Field Into First Name and Last Name

Split Name Field Into First Name and Last Name 12 years 1 month ago #21870

  • IanM
  • IanM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Is it possible to split a user entered value from a 'Name' field into hidden 'FirstName' and 'LastName' fields?

Thanks
The administrator has disabled public write access.

Split Name Field Into First Name and Last Name 2 years 8 months ago #42204

Looking for the same thing, albeit 9 years later :(
The administrator has disabled public write access.

Split Name Field Into First Name and Last Name 2 years 8 months ago #42205

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 246
  • Thank you received: 64
Use the following, try it in PHP sandbox then adapt to your form
$name = "James Smith";
 
$parts = explode(" ", $name);
if(count($parts) > 1) {
    $lastname = array_pop($parts);
    $firstname = implode(" ", $parts);
}
else
{
    $firstname = $name;
    $lastname = " ";
}
 
echo "Lastname: $lastname\n";
echo "Firstname: $firstname\n";
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
Last Edit: 2 years 8 months ago by iceferret.
The administrator has disabled public write access.
The following user(s) said Thank You: david.f.henry

Split Name Field Into First Name and Last Name 2 years 8 months ago #42206

Perfect, thanks.
d
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!