nash-ye/nslug

又一个 Unicode 软连接生成库。

v0.1.1 2016-10-16 22:00 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:25:17 UTC


README

Latest Stable Version Total Downloads License

又一个 Unicode 软连接生成库。

使用方法

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 截断字符限制,默认 null
  • delimiter string 分隔符,默认 -
  • lowercase bool 是否转换为小写?默认 true

安装

安装 nSlug 的支持方式是通过 Composer。

$ composer require nash-ye/nslug

要求

nSlug 需要 PHP 5.5+。