Yet another unicode slug generator library.
use NSlug\SlugGenerator;
$options = [
'limit' => null,
'delimiter' => '-',
'lowercase' => true,
];
$slugGenerator = new SlugGenerator($options);
// English strings.
echo $slugGenerator->generate('Hello World'); // Prints 'hello-world'.
echo $slugGenerator->generate('Life is too short!'); // Prints 'life-is-too-short'.
// Arabic strings.
echo $slugGenerator->generate('صباح جميل'); // Prints 'صباح-جميل'.
echo $slugGenerator->generate('مساء الخير'); // Prints 'مساء-الخير'.
limit
int|null The characters limit to truncate, defaultnull
.delimiter
string The delimiter, default-
.lowercase
bool Convert to lower-case?, defaulttrue
.
The supported way of installing nSlug is via Composer.
$ composer require nash-ye/nslug
nSlug requires PHP 5.5+.