此包已被弃用且不再维护。未建议替代包。

文本组件是一组用于字符串操作的方法。

v1.1.2 2019-01-08 09:43 UTC

This package is auto-updated.

Last update: 2020-09-08 13:55:50 UTC


README

version MIT License

文本组件是一组用于字符串操作的方法。

安装

composer require flextype-components/text

使用

use Flextype\Component\Text\Text;

转写函数,用于将文本从一种脚本转换为另一种脚本。

echo Text::translitIt('Привет');

从字符串中移除任何前导和尾随斜杠。

echo Text::trimSlashes('some text here/');

将字符串中的多个斜杠缩减为单个斜杠。

echo Text::reduceSlashes('some//text//here');

从字符串中移除单引号和双引号。

echo Text::stripQuotes('some "text" here');

将单引号和双引号转换为实体。

echo Text::quotesToEntities('some "text" here');

创建一个由字符组成的随机字符串。

echo Text::random();

将字符串_1添加到字符串中,或递增结尾数字以允许字符串_2、字符串_3等。

$str = Text::increment($str);

切割字符串

echo Text::cut('Some text here', 5);

小写

echo Text::lowercase('Some text here');

大写

echo Text::uppercase('some text here');

获取长度

echo Text::length('Some text here');

创建一个 lorem ipsum 文本。

echo Text::lorem(2);

从字符串中提取最后 $num 个字符。

echo Text::right('Some text here', 4);

从字符串中提取前 $num 个字符。

echo Text::left('Some text here', 4);

将换行符替换为 <br><br />

echo Text::nl2br("Some \n text \n here");

<br><br /> 替换为换行符。

echo Text::br2nl("Some <br /> text <br /> here");

将 & 转换为 &。

echo Text::ampEncode("M&CMS");

将 & 转换为 &。

echo Text::ampDecode("M&amp;CMS");

将纯文本转换为 html。

echo Text::toHtml('test');

创建安全字符串。用于创建安全的用户名或文件名。

$safe_string = Text::safeString('hello world');

加密字符串

$encrypt_string = Text::encryptString('password', 'string_salt');

许可

LICENSE