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

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

krlnwll/php-name-parser
=======================

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

1.0.3(9y ago)124PHPPHP ^5.3.3 || ^7.0

Since Feb 26Pushed 9y ago1 watchersCompare

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

READMEChangelog (4)DependenciesVersions (5)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).

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

**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:**

- Forked from [joshfraser/PHP-Name-Parser](https://github.com/joshfraser/PHP-Name-Parser)
- 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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 64.2% 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 ~2 days

Total

4

Last Release

3358d ago

### Community

Maintainers

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

---

Top Contributors

[![joshfraser](https://avatars.githubusercontent.com/u/982234?v=4)](https://github.com/joshfraser "joshfraser (43 commits)")[![krlnwll](https://avatars.githubusercontent.com/u/6677720?v=4)](https://github.com/krlnwll "krlnwll (8 commits)")[![anchepiece](https://avatars.githubusercontent.com/u/279146?v=4)](https://github.com/anchepiece "anchepiece (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)")[![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)")[![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/krlnwll-php-name-parser/health.svg)

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

###  Alternatives

[ericlagarda/nova-embed

Embed field for Laravel Nova

1220.1k](/packages/ericlagarda-nova-embed)

PHPackages © 2026

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