PHPackages                             curiolabs/name-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. curiolabs/name-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

curiolabs/name-parser
=====================

PHP library for parsing a string containing a full name into its parts

v1.3.2(7y ago)019MITPHPPHP &gt;=7.1

Since May 10Pushed 6y agoCompare

[ Source](https://github.com/curiolabs/name-parser)[ Packagist](https://packagist.org/packages/curiolabs/name-parser)[ RSS](/packages/curiolabs-name-parser/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (3)Versions (24)Used By (0)

THE ICONIC Name Parser
======================

[](#the-iconic-name-parser)

[![Build Status](https://camo.githubusercontent.com/fd1e3ede1d33743e0a68b8a4ab35ce684bf42b0ce8fe71c630847a4308e23e94/68747470733a2f2f7472617669732d63692e6f72672f437572696f4c6162732f6e616d652d7061727365722e7376673f6272616e63683d6d617374657226743d323031373035313631333038)](https://travis-ci.org/CurioLabs/name-parser)[![Coverage Status](https://camo.githubusercontent.com/aaec27ad8c32756d9aab8e9d4dc32aa6fe6adf4f1315eab72d2d505d09384500/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f437572696f4c6162732f6e616d652d7061727365722f62616467652e7376673f6272616e63683d6d617374657226743d323031373035313631333038)](https://coveralls.io/github/CurioLabs/name-parser?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f6a173b54cbc345d684b7a68252225596f34df68deb089b014e444b509756473/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f437572696f4c6162732f6e616d652d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657226743d323031373035313631333038)](https://scrutinizer-ci.com/g/CurioLabs/name-parser/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/ab03ce65e09bf2c8c78a6645be12d4e6589864e17021a9c91c21fc7fa4cd1714/68747470733a2f2f706f7365722e707567782e6f72672f437572696f4c6162732f6e616d652d7061727365722f762f737461626c653f743d323031373035313631333038)](https://packagist.org/packages/CurioLabs/name-parser)[![Total Downloads](https://camo.githubusercontent.com/2dc4a86ccb803ad81482c838429399fa6777c60cb88236a95db9fa1208d245cf/68747470733a2f2f706f7365722e707567782e6f72672f437572696f4c6162732f6e616d652d7061727365722f646f776e6c6f6164733f743d323031373035313631333038)](https://packagist.org/packages/CurioLabs/name-parser)[![License](https://camo.githubusercontent.com/c5c56daa245b4b9c87bbcd4c5a0f5edcfdb7323e01d0d3f7043d10622d083045/68747470733a2f2f706f7365722e707567782e6f72672f437572696f4c6162732f6e616d652d7061727365722f6c6963656e73653f743d323031373035313631333038)](https://packagist.org/packages/CurioLabs/name-parser)

Purpose
-------

[](#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
--------

[](#features)

### Supported patterns

[](#supported-patterns)

This parser is able to handle name patterns with and without comma:

```
... [firstname] ... [lastname] ...

```

```
... [lastname] ..., ... [firstname] ...

```

```
... [lastname] ..., ... [firstname] ..., [suffix]

```

### Supported parts

[](#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

[](#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
--------

[](#examples)

More than 80 different successfully parsed name patterns can be found in the [parser unit test](https://github.com/CurioLabs/name-parser/blob/master/tests/ParserTest.php#L12-L12).

Setup
-----

[](#setup)

```
composer require CurioLabs/name-parser

```

Usage
-----

[](#usage)

### Basic usage

[](#basic-usage)

```
