Download the PHP package curiolabs/name-parser without Composer
On this page you can find all versions of the php package curiolabs/name-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download curiolabs/name-parser
More information about curiolabs/name-parser
Files in curiolabs/name-parser
Package name-parser
Short Description PHP library for parsing a string containing a full name into its parts
License MIT
Informations about the package name-parser
THE ICONIC Name Parser
Purpose
This is a universal, language-independent name parser.
Its purpose is to split a single string containing a full name, possibly including salutation, initials, suffixes etc., into meaningful parts like firstname, lastname, initials, and so on.
It is mostly tailored towards english names but works pretty well with non-english names as long as they use latin spelling.
E.g. Mr Anthony R Von Fange III is parsed to
- salutation: Mr.
- firstname: Anthony
- initials: R
- lastname: von Fange
- suffix: III
Features
Supported patterns
This parser is able to handle name patterns with and without comma:
Supported parts
- salutations (e.g. Mr, Mrs, Dr, etc.)
- first name
- middle names
- initials (single letters, possibly followed by a dot)
- nicknames (parts within parenthesis, brackets etc.)
- last names (also supports prefixes like von, de etc.)
- suffixes (Jr, Senior, 3rd, PhD, etc.)
Other features
- multi-language support for salutations, suffixes and lastname prefixes
- customizable nickname delimiters
- customizable normalisation of all output strings (original values remain accessible)
- customizable whitespace
Examples
More than 80 different successfully parsed name patterns can be found in the parser unit test.
Setup
Usage
Basic usage
An empty string is returned for missing parts.
Special part retrieval features
Explicit last name parts
You can retrieve last name prefixes and pure last names separately with
Nick names with normalized wrapping
By default, getNickname()
returns the pure string of nick names. However, you can
pass true
to have the same normalised parenthesis wrapping applied as in echo $name
:
Setting Languages
Setting nickname delimiters
Setting whitespace characters
Limiting the position of salutations
This will require salutations to appear within the first two words of the given input string. This defaults to half the amount of words in the input string, meaning that effectively the salutation may occur within the first half of the name parts.
License
THE ICONIC Name Parser library for PHP is released under the MIT License.