Return to Snippet

Revision: 59777
at September 29, 2012 22:38 by shin


Initial Code
function descr_excerpt($string, $width)
{
$your_desired_width = $width;
$string = mb_substr($string, 0, $your_desired_width+1);

if (strlen($string) > $your_desired_width)
{
    $string = wordwrap($string, $your_desired_width);
    $i = strpos($string, "\n");
    if ($i) {
        $string = mb_substr($string, 0, $i);
    }
}
return $string;
}

Initial URL

                                

Initial Description
cut string without partial words (unicode version with mb_substr). for this snippet: http://snipplr.com/view/67385/show-subcategories-with-picture-and-description/

Initial Title
cut string without partial words (unicode version with mb_substr)

Initial Tags

                                

Initial Language
PHP