我有以下代碼,並且只需要在描述中回顯出100個或更少的字,而不是整個描述。無論如何,通過編輯這段代碼來做到這一點?PHP描述摘要
public static function getExcerpt($profile) {
$out='';
if(!empty($profile['description'])) {
$out.=$profile['description'].' '.__('', 'lovestory');
}
return $out;
}
謝謝!
存在。我建議你看看php文檔,特別是字符串搜索函數:你正在尋找一種方法來搜索字符串中第100個空白字符的發生。 – arkascha