返回字符串前N个单词的PHP函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了返回字符串前N个单词的PHP函数相关的知识,希望对你有一定的参考价值。
function shorten_string($string, $wordsreturned) /* Returns the first $wordsreturned out of $string. If string contains more words than $wordsreturned, the entire string is returned.*/ { $retval = $string; // Just in case of a problem /* Already short enough, return the whole thing*/ { $retval = $string; } /* Need to chop of some words*/ else { } return $retval; }
以上是关于返回字符串前N个单词的PHP函数的主要内容,如果未能解决你的问题,请参考以下文章