PHPackages                             aait/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. aait/php-name-parser

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

aait/php-name-parser
====================

PHP library to split names into their respective components (first, last, etc). Fork of joshfraser/PHP-Name-Parser

1.0.1(8y ago)011.2k1[1 PRs](https://github.com/aait/PHP-Name-Parser/pulls)1Apache-2.0PHPPHP ~5.3.0|~5.4.0|~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0

Since Aug 11Pushed 4y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (1)

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).

**Usage:**

```
include("parser.php");

$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.

**To-do**

- Handle the "Lname, Fname" format
- Support non-English names (handle unicode characters &amp; better understand global naming rules)
- Separate the parsing of the name from the normalization &amp; capitalization &amp; make those optional.
- 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)

**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) and [Josh Houghtelin](https://github.com/jhoughtelin) 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

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.1% 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.

###  Release Activity

Cadence

Every ~433 days

Total

2

Last Release

3176d ago

PHP version history (2 changes)1.0.0PHP ~5.3.0|~5.4.0|~5.5.0|~5.6.0|~7.0.0

1.0.1PHP ~5.3.0|~5.4.0|~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6286270?v=4)[AAIT](/maintainers/AAIT)[@aait](https://github.com/aait)

---

Top Contributors

[![joshfraser](https://avatars.githubusercontent.com/u/982234?v=4)](https://github.com/joshfraser "joshfraser (35 commits)")[![jhoughtelin](https://avatars.githubusercontent.com/u/6137941?v=4)](https://github.com/jhoughtelin "jhoughtelin (3 commits)")[![aait](https://avatars.githubusercontent.com/u/6286270?v=4)](https://github.com/aait "aait (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/aait-php-name-parser/health.svg)

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

###  Alternatives

[infinum/eightshift-libs

WordPress libs developed by Eightshift team to use in modern WordPress.

63123.8k3](/packages/infinum-eightshift-libs)[still-code/ar-php-laravel

ar-php-laravel

397.5k](/packages/still-code-ar-php-laravel)

PHPackages © 2026

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