PHP code example of enzyme / name

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

    

enzyme / name example snippets


use Enzyme\Name\Simple;

$name = Simple::fromString('Hubert Cumberdale');
echo $name->getFirst(); // Hubert
echo $name->getLast(); // Cumberdale

use Enzyme\Name\Simple;
use Enzyme\Name\Format;

$name = Simple::fromString('Hubert Cumberdale');
$fmt = Format($name);

echo $fmt->like('First'); // Hubert
echo $fmt->like('First L.'); // Hubert C.
echo $fmt->like('Last, F.'); // Cumberdale, H.

// Quickfire option.
echo Format::nameLike($name, 'First L.'); // Hubert C.

use Enzyme\Name\Simple;
use Enzyme\Name\Format;

$name = Simple::fromString('Dr. Hubert Alberto Cumberdale');

echo Format::nameLike($name, 'First M. Last'); // Hubert A. Cumberdale
echo Format::nameLike($name, 'P. First M. Last'); // Dr. Hubert A. Cumberdale
echo Format::nameLike($name, 'P. Last, F. M.'); // Dr. Cumberdale, H. A.