note 90246 added to function.utf8-decode

From: Date: Sun, 12 Apr 2009 03:39:15 +0000
Subject: note 90246 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-153110@lists.php.net to get a copy of this message
I've found a solution for cutting an article's summary to make preview text which contains 'utf-8' unicode, without broken words. I hope this might help. function prevText($str, $limit){ $result = ""; $str = trim($str); if (mb_strlen($str,'utf-8') <= $limit) return $str.'...'; $words = explode(' ',$str); $i = 0; while (mb_strlen($result.$words[$i],'utf-8') <= $limit){ $result .= $words[$i].' '; $i++; } return trim($result).'...'; } ---- Server IP: 210.245.120.83 Probable Submitter: 123.16.234.100 ---- Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php Edit -- https://master.php.net/note/edit/90246 Del: integrated -- https://master.php.net/note/delete/90246/integrated Del: useless -- https://master.php.net/note/delete/90246/useless Del: bad code -- https://master.php.net/note/delete/90246/bad+code Del: spam -- https://master.php.net/note/delete/90246/spam Del: non-english -- https://master.php.net/note/delete/90246/non-english Del: in docs -- https://master.php.net/note/delete/90246/in+docs Del: other reasons-- https://master.php.net/note/delete/90246 Reject -- https://master.php.net/note/reject/90246 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153110) next »