PHPackages                             compwright/full-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. compwright/full-name-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

compwright/full-name-parser
===========================

Parses a human name

v1.0.0(5mo ago)01.3k—8.3%MITPHPPHP ^8.3CI passing

Since Nov 26Pushed 5mo agoCompare

[ Source](https://github.com/compwright/full-name-parser)[ Packagist](https://packagist.org/packages/compwright/full-name-parser)[ RSS](/packages/compwright-full-name-parser/feed)WikiDiscussions master Synced 1mo ago

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

full-name-parser
================

[](#full-name-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/6d956f63b65b633a7f5eaeaf1f25c20cf196846ba24ced740d68acf6a0209f34/68747470733a2f2f706f7365722e707567782e6f72672f636f6d707772696768742f66756c6c2d6e616d652d7061727365722f762f737461626c65)](https://github.com/compwright/full-name-parser/releases/latest)[![License](https://camo.githubusercontent.com/03a9efd3587be5e921049514539f2c70c6b54adef8a3dd0e6fb9eac74d50c139/68747470733a2f2f706f7365722e707567782e6f72672f636f6d707772696768742f66756c6c2d6e616d652d7061727365722f6c6963656e7365)](https://opensource.org/licenses/MIT)[![Tests](https://github.com/compwright/full-name-parser/actions/workflows/php.yml/badge.svg)](https://github.com/compwright/full-name-parser/actions/workflows/php.yml)

> This is a maintained fork of the abandoned package . It has been updated for PHP 8.3+.

Description
-----------

[](#description)

FullNameParser is designed to parse large batches of full names in multiple inconsistent formats, as from a database, and continue processing without error, even if given some unparsable garbage entries.

FullNameParser::parse():

1. accepts a string containing a person's full name, in any format,
2. analyzes and attempts to detect the format of that name,
3. (if possible) parses the name into its component parts, and
4. (by default) returns an object containing all individual parts of the name:
    - title (string): title(s) (e.g. "Ms." or "Dr.")
    - first (string): first name or initial
    - middle (string): middle name(s) or initial(s)
    - last (string): last name or initial
    - nick (string): nickname(s)
    - suffix (string): suffix(es) (e.g. "Jr.", "II", or "Esq.")
    - error (array of strings): any parsing error messages

Optionally, FullNameParser can also:

- return only the specified part of a name as a string (or errors as an array)
- always fix or ignore the letter case of the returned parts (the default is to fix the case only when the original input is all upper or all lowercase)
- stop on errors (the default is to return warning messages in the output, but never throw a PHP error, no matter how mangled the input)

Now FullNameParser cannot:

- detect more variations of name prefixes, suffixes, and titles (the default detects 29 prefixes, 19 suffixes, 16 titles, and 8 conjunctions, but in future it can be set to detect 97 prefixes, 23 suffixes, and 204 titles instead)

If this is not what you're looking for, is overkill for your application, or is in the wrong language, check the "Credits" section at the end of this file for links to other parsers which may suit your needs better.

Use
---

[](#use)

### Basic Use

[](#basic-use)

```
