Skip to content

Instantly share code, notes, and snippets.

@msng
Created November 28, 2011 04:25
Show Gist options
  • Save msng/1399098 to your computer and use it in GitHub Desktop.
Save msng/1399098 to your computer and use it in GitHub Desktop.
<?php
function mb_strimlen($str, $start, $length, $trimmarker = '', $encoding = false) {
$encoding = $encoding ? $encoding : mb_internal_encoding();
$str = mb_substr($str, $start, mb_strlen($str), $encoding);
if (mb_strlen($str, $encoding) > $length) {
$markerlen = mb_strlen($trimmarker, $encoding);
$str = mb_substr($str, 0, $length - $markerlen, $encoding) . $trimmarker;
}
return $str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment