reset and begin
8/02/2012

php Code cắt chuỗi làm trích dẫn trong tiêu đề hoặc bài viết

Code đuợc dùng để rút ngắn bớt khi nội dung quá dài

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ồn
http://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

Bloger Comments
G+ Comments
Comments FaceBook

No comments:

List

Profiles Information


About me : Nothing is 1 vài thứ - 1985

Places I've Lived : I Hà Nội

Home Page : http://www.shimivn.blogspot.com/

Think : 1:1000000000

Languages spoken : Vietnamese,English.

Mobile : sony C2305

dell : i3-Ram 3GB- HDD 250GB .