joan/ yii2-widget-stringmanipulation
字符串处理
dev-master
2021-01-25 08:46 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-25 16:39:54 UTC
README
字符串处理
安装
安装此扩展的首选方式是通过 composer。
运行以下命令之一:
composer require joan/yii2-widget-stringmanipulation "dev-master"
或者
"joan/yii2-widget-stringmanipulation": "dev-master"
将以下内容添加到您的 composer.json
文件的 require 部分。
使用方法
扩展安装后,只需在代码中通过以下方式使用它:
1.- 最小化到特定数量的字符。
use joan\string\StringManipulation; <?= StringManipulation::widget([ 'type' => StringManipulation::TYPE_MINIMIZE_STRING, 'string' => "Oh, you can't help that,'said the Cat:' we're all mad here. I'm mad. You're mad.", 'length' => 40, ]) ?>
Result => Oh, you can't help that,'said the Cat...
2.- 删除符号。
use joan\string\StringManipulation; <?= StringManipulation::widget([ 'type' => StringManipulation::TYPE_REMOVE_SIGN, 'string' => "Oh, $ you can't help that,'@said the Cat:' we're*all mad here. I'm mad.*You're mad.", ]) ?>
Result => Oh you can t help that said the Cat we re all mad here I m mad You re mad
2.- 随机。
use joan\string\StringManipulation; <?= StringManipulation::widget([ 'type' => StringManipulation::TYPE_RANDOM_STRING, 'length' => 20, ]) ?>
Result => iGCS3gDGD3eZvgC5ZGDC