Problem with 'substr' PHP function on non english characters
-
Hello!
‘substr‘ php function get error character in end of non english character string.I offer to use this function insted:
function _substr($str, $length, $minword = 3) { $sub = ''; $len = 0; foreach (explode(' ', $str) as $word) { $part = (($sub != '') ? ' ' : '') . $word; $sub .= $part; $len += strlen($part); if (strlen($word) > $minword && strlen($sub) >= $length) { break; } } return strtolower($sub . (($len < strlen($str)) ? '...' : '')); }Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Problem with 'substr' PHP function on non english characters’ is closed to new replies.