Laravel与CI框架中截取字符串函数
程序员文章站
2023-12-20 18:25:40
laravel:
function limit($value, $limit = 100, $end = '...')
{
if (mb_strwidth...
laravel:
function limit($value, $limit = 100, $end = '...') { if (mb_strwidth($value, 'utf-8') <= $limit) { return $value; } return rtrim(mb_strimwidth($value, 0, $limit, '', 'utf-8')).$end; }
ci:
function word_limiter($str, $limit = 100, $end_char = '…') { if (trim($str) === '') { return $str; } preg_match('/^\s*+(?:\s++\s*+){1,'.(int) $limit.'}/', $str, $matches); if (strlen($str) === strlen($matches[0])) { $end_char = ''; } return rtrim($matches[0]).$end_char; }
推荐阅读
-
Laravel与CI框架中截取字符串函数
-
Laravel与CI框架中截取字符串函数 安卓截取字符串 jstl截取字符串 数据库截取字符
-
Laravel与CI框架中截取字符串函数,laravelci_PHP教程
-
Laravel与CI框架中截取字符串函数_PHP
-
Laravel与CI框架中截取字符串函数,laravelci
-
Laravel与CI框架中截取字符串函数,laravelci
-
Laravel与CI框架中截取字符串函数_PHP
-
Laravel与CI框架中截取字符串函数 安卓截取字符串 jstl截取字符串 数据库截取字符
-
Laravel与CI框架中截取字符串函数_php技巧
-
Laravel与CI框架中截取字符串函数_php技巧