emanuelecoppola / smartwrap
更智能的PHP文本换行
0.0.2
2020-06-07 15:12 UTC
Requires
- php: ^7.0.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-09-07 04:34:17 UTC
README
我编写这个包是因为我遇到了和这个StackOverflow问题相同的问题。
安装
composer require emanuelecoppola/smartwrap
用法
use EmanueleCoppola\SmartWrap\SmartWrap; $sw = new SmartWrap(); $wrapped = $sw->smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true); print($wrapped); // Or by using the global function $wrapped = smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true); print($wrapped);
示例输入/输出
$output = wordwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true); // The output will be ↓ $output == "hello!\nheeeeeeeeeeeeeeereis\naverylongword"; $output = smartwrap('hello! heeeeeeeeeeeeeeereisaverylongword', 20, "\n", true); // The output will be ↓ $output == "hello! heeeeeeeeeeee\neeereisaverylongword";