PHPackages                             alignwebs/php-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. alignwebs/php-name-parser

ActiveLibrary

alignwebs/php-name-parser
=========================

PHP library to split names into their respective components (first, last, etc)

62.1k2PHP

Since Jan 14Pushed 4y agoCompare

[ Source](https://github.com/alignwebs/PHP-Name-Parser)[ Packagist](https://packagist.org/packages/alignwebs/php-name-parser)[ RSS](/packages/alignwebs-php-name-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Name-Parser
===============

[](#php-name-parser)

PHP library to split names into their respective components. Besides detecting first and last names, this library attempts to handle prefixes, suffixes, initials and compound last names like "Von Fange". It also normalizes prefixes (Mister -&gt; Mr.) and fixes capitalization (JOHN SMITH -&gt; John Smith).

**Installation:**

```
composer require alignwebs/php-name-parser

```

**Usage:**

```
use FullNameParser\FullNameParser;

$parser = new FullNameParser();
$parser->parse_name("Mr Anthony R Von Fange III");

```

**Results:**

```
Array (
    [nickname] =>
    [salutation] => Mr.
    [fname] => Anthony
    [initials] => R
    [lname] => Von Fange
    [suffix] => III
)

```

**The algorithm:**

We start by splitting the full name into separate words. We then do a dictionary lookup on the first and last words to see if they are a common prefix or suffix. Next, we take the middle portion of the string (everything minus the prefix &amp; suffix) and look at everything except the last word of that string. We then loop through each of those words concatenating them together to make up the first name. While we’re doing that, we watch for any indication of a compound last name. It turns out that almost every compound last name starts with 1 of 16 prefixes (Von, Van, Vere, etc). If we see one of those prefixes, we break out of the first name loop and move on to concatenating the last name. We handle the capitalization issue by checking for camel-case before uppercasing the first letter of each word and lowercasing everything else. I wrote special cases for periods and dashes. We also have a couple other special cases, like ignoring words in parentheses all-together.

Check examples.php for the test suite and examples of how various name formats are parsed.

**Possible improvements**

- Handle the "Lname, Fname" format
- Separate the parsing of the name from the normalization &amp; capitalization &amp; make those optional
- Seperate the dictionaries from the code to make it easier to do localization
- Add common name libraries to allow for things like gender detection

**Same logic, different languages**

- [Name Parser in Java](https://github.com/gkhays/NameParser)
- [Name Parser in JavaScript](https://github.com/joshfraser/JavaScript-Name-Parser)
- [Name Parser in CSharp](https://github.com/ianlee74/CSharp-Name-Parser)

**Credits &amp; license:**

- Read more about the inspiration for this [PHP Name Parser](http://www.onlineaspect.com/2009/08/17/splitting-names/) library by [Josh Fraser](http://joshfraser.com)
- Special thanks to [Josh Jones](https://github.com/UberNerdBoy), [Timothy Wood](https://github.com/codearachnid), [Michael Waskosky](https://github.com/waskosky), [Eric Celeste](https://github.com/efc), [Josh Houghtelin](https://github.com/jhoughtelin) and [monitaure](https://www.github.com/monitaure) for their contributions. Pull requests are always welcome as long as you don't break the test suite.
- Released under Apache 2.0 license

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 61.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1d83a19b3a5a02ffef0c80e4571be1253d7446a072ec6496217a59c0911f93d?d=identicon)[alignwebs](/maintainers/alignwebs)

---

Top Contributors

[![joshfraser](https://avatars.githubusercontent.com/u/982234?v=4)](https://github.com/joshfraser "joshfraser (47 commits)")[![anchepiece](https://avatars.githubusercontent.com/u/279146?v=4)](https://github.com/anchepiece "anchepiece (5 commits)")[![alignwebs](https://avatars.githubusercontent.com/u/7644807?v=4)](https://github.com/alignwebs "alignwebs (5 commits)")[![squatto](https://avatars.githubusercontent.com/u/748444?v=4)](https://github.com/squatto "squatto (5 commits)")[![jhoughtelin](https://avatars.githubusercontent.com/u/6137941?v=4)](https://github.com/jhoughtelin "jhoughtelin (3 commits)")[![Toxaris-NL](https://avatars.githubusercontent.com/u/6073394?v=4)](https://github.com/Toxaris-NL "Toxaris-NL (3 commits)")[![arnidan](https://avatars.githubusercontent.com/u/5755685?v=4)](https://github.com/arnidan "arnidan (2 commits)")[![jenky](https://avatars.githubusercontent.com/u/1808758?v=4)](https://github.com/jenky "jenky (2 commits)")[![atla5](https://avatars.githubusercontent.com/u/5565284?v=4)](https://github.com/atla5 "atla5 (1 commits)")[![krlnwll](https://avatars.githubusercontent.com/u/6677720?v=4)](https://github.com/krlnwll "krlnwll (1 commits)")[![luiz-brandao](https://avatars.githubusercontent.com/u/704231?v=4)](https://github.com/luiz-brandao "luiz-brandao (1 commits)")[![waskosky](https://avatars.githubusercontent.com/u/2141654?v=4)](https://github.com/waskosky "waskosky (1 commits)")

### Embed Badge

![Health badge](/badges/alignwebs-php-name-parser/health.svg)

```
[![Health](https://phpackages.com/badges/alignwebs-php-name-parser/health.svg)](https://phpackages.com/packages/alignwebs-php-name-parser)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
