PHP code example of zelenin / string

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

    

zelenin / string example snippets


$string = 'Jeanne Françoise Julie Adélaïde Récamier';
$transformers = [
	new IntlNormalizeTransformer(),
	new IntlTransliterateTransformer(),
	new UrlifyTransformer(),
	new TemplateTransformer('{id}-{slug}', ['{id}' => $model->id])
];
$transformer = new Transformer(new TransformerCollection($transformers));
$slug = $transformer->transform($string); // '12-jeanne-francoise-julie-adelaide-recamier'

$string = 'Jeanne Françoise Julie Adélaïde Récamier';
$transformers = [
	new IntlNormalizeTransformer(Normalizer::FORM_C),
	new IntlTransliterateTransformer('Russian-Latin/BGN; Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFKC;'),
	new UrlifyTransformer('_', false),
	new TemplateTransformer('{id}-{slug}', ['{id}' => $model->id])
];
$transformer = new Transformer(new TransformerCollection($transformers));
$slug = $transformer->transform($string);

php composer.phar