1

我在文本助手中使用 codeigniter word_limiter() 函数。

$string = "Here is a nice text string consisting of eleven words.";

$string = word_limiter($string, 4);

// Returns: Here is a nice…

上述函数将输出限制为四个字。我怎样才能也将限制后的单词存储在变量中以供使用???

4

1 回答 1

5

尝试这个:

$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));
于 2012-07-05T08:25:45.627 回答