chrisullyott / human-name-parser
A human name parser written in PHP.
Installs: 63 434
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 2
Forks: 4
Open Issues: 0
pkg:composer/chrisullyott/human-name-parser
Requires
- php: >=5.4.0
 
Requires (Dev)
- phpunit/phpunit: 3.7.*
 
This package is auto-updated.
Last update: 2025-10-29 01:57:17 UTC
README
A human name parser written in PHP.
Based on Josh Fraser's PHP-Name-Parser. I attempted to rewrite the library to be more easily understandable (at least to myself). Nearly all the original features are maintained.
The algorithm first sanitizes a name string, and then breaks it into smaller pieces using a library of professional titles and suffixes.
Installation
Include in your project, or, install with Composer:
$ composer require chrisullyott/human-name-parser
Parsing a name
use ChrisUllyott\HumanNameParser; $parser = new HumanNameParser('Dr. martin luther king jr'); print_r($parser->parse());
Array
(
    [full]       => Dr. Martin Luther King Jr.
    [salutation] => Dr.
    [first]      => Martin
    [middle]     => Luther
    [last]       => King
    [suffix]     => Jr.
)
Methods
| Name | Sample output | 
|---|---|
| getFullName() | Dr. Martin Luther King Jr. | 
| getSalutation() | Dr. | 
| getFirstName() | Martin | 
| getMiddleName() | Luther | 
| getLastName() | King | 
| getSuffix() | Jr. |