PHP code example of curiolabs / name-parser

1. Go to this page and download the library: Download curiolabs/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/ */

    

curiolabs / name-parser example snippets




$parser = new CurioLabs\NameParser\Parser();

$name = $parser->parse($input);

echo $name->getSalutation();
echo $name->getFirstname();
echo $name->getLastname();
echo $name->getMiddlename();
echo $name->getNickname();
echo $name->getInitials();
echo $name->getSuffix();

print_r($name->getAll()); // all parts as an associative array

echo $name; // re-prints the full normalised name

echo $name->getLastnamePrefix();
echo $name->getLastname(true); // true enables strict mode for pure lastnames, only

echo $name->getNickname(); // The Giant
echo $name->getNickname(true); // (The Giant)

$parser = new CurioLabs\NameParser\Parser([
    new CurioLabs\NameParser\Language\English(), //default
    new CurioLabs\NameParser\Language\German(),
])

$parser = new CurioLabs\NameParser\Parser();
$parser->setNicknameDelimiters(['(' => ')']);

$parser = new CurioLabs\NameParser\Parser();
$parser->setWhitespace("\t _.");

$parser = new CurioLabs\NameParser\Parser();
$parser->setMaxSalutationIndex(2);