PHP code example of phabloraylan / human-name-parser

1. Go to this page and download the library: Download phabloraylan/human-name-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phabloraylan / human-name-parser example snippets


use HumanNameParser\Parser;

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

	echo "Hello " . $name->getFirstName();
	echo "Hello " . $name->getLeadingInitial();
	echo "Hello " . $name->getFirstName();
	echo "Hello " . $name->getNickNames();
	echo "Hello " . $name->getMiddleName();
	echo "Hello " . $name->getLastName();
	echo "Hello " . $name->getSuffix();
	
} catch(HumanNameParser\Exception\FirstNameNotFoundException $e) {
	// catch body
} catch(HumanNameParser\Exception\LastNameNotFoundException $e) {
	// catch body
}