1. Go to this page and download the library: Download geocurly/name-splitter 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/ */
geocurly / name-splitter example snippets
declare(strict_types=1);
use NameSplitter\NameSplitter;
$splitter = new NameSplitter(['enc' => 'CP1251']);
$result = $splitter->split('Иванов Иван Иванович');
[$surname, $name, $middleName] = [
$result->getSurname(),
$result->getName(),
$result->getMiddleName(),
];
declare(strict_types=1);
use NameSplitter\{
NameSplitter,
Template\SimpleMatch,
Contract\TemplateInterface as TPL,
Contract\StateInterface
};
$before = [
// for this case we explicitly match name parts with template
new SimpleMatch([
TPL::SURNAME => 'Difficult Surname',
TPL::NAME => 'Difficult Name'
]),
static function(StateInterface $state) {
// TODO there is will be your implementation
return [
TPL::SURNAME => $surname ?? null,
TPL::NAME => $name ?? null,
];
},
];
// There are may be any callable types if they take to input the StateInterface
$after = [];
$splitter = new NameSplitter([], $before, $after);
$result = $splitter->split('Difficult Surname Difficult Name');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.