PHP code example of jsor / string-formatter

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

    

jsor / string-formatter example snippets


use Jsor\NameFormatter;

$nameParts = [
    'given_name' => 'John',
    'family_name' => 'Doe',
    'salutation' => 2 // name_mr
];

$enUsFormatter = new NameFormatter('en_US');
echo $enUsFormatter->format($nameParts)."\n";

$deDeFormatter = new NameFormatter('de_DE');
echo $deDeFormatter->format($nameParts)."\n";

$zhCnFormatter = new NameFormatter('zh_CN');
echo $zhCnFormatter->format($nameParts)."\n";

use Jsor\NameFormatter;

$formatter = new NameFormatter('en_US', '%d%t%g%t%m%t%f');
echo $formatter->format([
    'given_name' => 'John',
    'family_name' => 'Doe',
    'salutation' => 'Mr.',
]);