PHP code example of slowprog / petrovich-php

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

    

slowprog / petrovich-php example snippets




$petrovich = new Petrovich();

$firstname  = "Александр";
$middlename = "Сергеевич";
$lastname   = "Пушкин";
$fullName   = 'Васильков Генадий Павлович';

echo $petrovich->detectGender("Петровна"); // Petrovich::GENDER_FEMALE (см. пункт Пол)

echo $petrovich->firstname($firstname, Petrovich::CASE_GENITIVE, Petrovich::GENDER_MALE); // Александра

echo $petrovich->middlename($middlename, Petrovich::CASE_GENITIVE, Petrovich::GENDER_MALE); // Сергеевича

echo $petrovich->lastname($lastname, Petrovich::CASE_GENITIVE, Petrovich::GENDER_MALE); // Пушкина

echo $mihalich->initial($fullName); // Васильков Г. П.

echo $mihalich->inflectFullName($fullName, Petrovich::CASE_GENITIVE); // Василькова Генадия Павловича

echo $mihalich->initial(
    $mihalich->inflectFullName(
        $fullName, 
        Petrovich::CASE_GENITIVE
    )
); // Василькова Г. П.