Skip to main content
added 3 characters in body
Source Link
Tudor Constantin
  • 26.9k
  • 7
  • 54
  • 73

try with mb_substr() :

static function short($string, $max = 255){ if(strlenmb_strlen($string, 'utf-8') >= $max){ $string = mb_substr($string, 0, $max - 5, 'utf-8').'...'; } return $string; } 

try with mb_substr() :

static function short($string, $max = 255){ if(strlen($string) >= $max){ $string = mb_substr($string, 0, $max - 5, 'utf-8').'...'; } return $string; } 

try with mb_substr() :

static function short($string, $max = 255){ if(mb_strlen($string, 'utf-8') >= $max){ $string = mb_substr($string, 0, $max - 5, 'utf-8').'...'; } return $string; } 
Source Link
Tudor Constantin
  • 26.9k
  • 7
  • 54
  • 73

try with mb_substr() :

static function short($string, $max = 255){ if(strlen($string) >= $max){ $string = mb_substr($string, 0, $max - 5, 'utf-8').'...'; } return $string; }