public function getPagesummary($id=null){
$model= Model::model()->findByPk($id);
$wordlimit= strip_tags($model->details);
if (str_word_count($wordlimit, 0) > 40) {
$words = str_word_count($wordlimit, 2);
$pos = array_keys($words);
$textt = substr($wordlimit, 0, $pos[40]) . '...';
return $textt;
}
else
return $wordlimit;
}
public function limitWords($id, $limit=50) {
$model= Model::model()->findByPk($id);
$text= strip_tags($model->details);
$word_arr = explode(" ", $text);
if (count($word_arr) > $limit) {
$words = implode(" ", array_slice($word_arr , 0, $limit) ) . ' ...';
return $words;
}
return $text;
}
$model->getPagesummary($model->id)
$model->limitWords($model->id)
Sunday, September 6, 2015
Limit Content Length in Yii
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment