Parses a human name

1.0.0 2019-03-10 15:43 UTC

This package is auto-updated.

Last update: 2024-05-06 16:57:46 UTC


68747470733a2f2f7472617669732d63692e6f72672f6461766964676f726765732f48756d616e4e616d655061727365722e7068702e706e67 Latest Stable Version PHPStan Enabled

Note: The 1.0 release requires PHP > 7.1.


Fork from HumanNameParser.php origninally by Jason Priem jason@jasonpriem.com. Takes human names of arbitrary complexity and various wacky formats like:

  • J. Walter Weatherman
  • de la Cruz, Ana M.
  • James C. ('Jimmy') O'Dell, Jr.
  • Dr. James C. ('Jimmy') O'Dell, Jr.

and parses out the:

  • leading initial (Like "J." in "J. Walter Weatherman")
  • first name (or first initial in a name like 'R. Crumb')
  • nicknames (like "Jimmy" in "James C. ('Jimmy') O'Dell, Jr.")
  • middle names
  • last name (including compound ones like "van der Sar' and "Ortega y Gasset"), and
  • suffix (like 'Jr.', 'III')
  • title (like 'Dr.', 'Prof') new

How to use

use HumanNameParser\Parser;

$nameparser = new Parser();
$name = $nameparser->parse("Alfonso Ribeiro");

echo "Hello " . $name->getFirstName();