function thunho($noidung,$num){
$limit = $num - 1 ;
$str_tmp = '';
$arrstr = explode(" ", $noidung);
if ( count($arrstr) <= $num ) { return $noidung; }
if (!empty($arrstr)) {
for ( $j=0; $j< count($arrstr) ; $j++) {
$str_tmp .= " " . $arrstr[$j];
if ($j == $limit)
{ break; }
}
}
return $str_tmp.'...';
}
nguồnhttp://dwebvn.com/forum/showthread.php?730-%C4%90o%E1%BA%A1n-Code-c%E1%BA%AFt-chu%E1%BB%97i-l%C3%A0m-tr%C3%ADch-d%E1%BA%ABn-trong-ti%C3%AAu-%C4%91%E1%BB%81-ho%E1%BA%B7c-b%C3%A0i-vi%E1%BA%BFt
No comments: