以str_为前缀的函数执行在处理字符串时有用的任务。 帮助程序直接映射到Str PHP类及其方法。 例如:
{{ str_camel() }}
对应的PHP的方法如下:
<?= Str::camel() ?>
注意: camelCase驼峰命名中的方法应转换为snake_case下划线命名。
限制字符串中的字符数。
{{ str_limit('The quick brown fox...', 100) }}
要在应用限制时添加后缀,请将其作为第三个参数传递。 默认为“...”。
{{ str_limit('The quick brown fox...', 100, '... Read more!') }}
限制字符串中的单词数。
{{ str_words('The quick brown fox...', 100) }}
要在应用限制时添加后缀,请将其作为第三个参数传递。 默认为“...”。
{{ str_words('The quick brown fox...', 100, '... Read more!') }}
将值转换为camelCase。
// 输出: helloWorld
{{ str_camel('hello world') }}
将值转换为StudlyCase。
// 输出: HelloWorld
{{ str_studly('hello world') }}
将值转换为snake_case。
// 输出: hello_world
{{ str_snake('hello world') }}
第二个参数可以提供分隔符。
// 输出: hello---world
{{ str_snake('hello world', '---') }}
获取复数形式的英文单词。
// 输出: chickens
{{ str_plural('chicken') }}