我在文本助手中使用了codeigniter word_limiter()函数。
$string = "Here is a nice text string consisting of eleven words.";
$string = word_limiter($string, 4);
// Returns: Here is a nice…
以上功能将输出限制为四个字。我怎样才能将限制后的单词存储在变量中以供使用?
答案 0 :(得分:4)
试试这个:
$original_string = "Here is a nice text string consisting of eleven words.";
$limited_string = word_limiter($original_string , 4, '');
$rest_of_string = trim(str_replace($limited_string, "", $original_string));