noptin_split_subscriber_name( $name )
Converts a name field into the first and last name
Description Description
Simple Function, Using Regex (word char and hyphens) It makes the assumption the last name will be a single word. Makes no assumption about middle names, that all just gets grouped into first name. You could use it again, on the "first name" result to get the first and middle though.
Source Source
File: includes/subscriber.php
function noptin_split_subscriber_name( $name ) { $name = trim( $name ); $last_name = ( strpos( $name, ' ' ) === false ) ? '' : preg_replace( '#.*\s([\w-]*)$#', '$1', $name ); $first_name = trim( preg_replace( '#' . $last_name . '#', '', $name ) ); return array( $first_name, $last_name ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.5 | Introduced. |