Welcome Guest, Not a member yet? Register   Sign In
not correct work of the function character_limiter for not latin symbols
#5

[eluser]emperius[/eluser]
this also didn't helped

may be I'm doing somthing wrong?

Code:
function character_limiter($str, $n = 500, $end_char = '…')
{
    if (iconv_strlen($str, 'UTF-8') < $n)
    {
        return $str;
    }
        
    $str = preg_replace("/\s+/", ' ', preg_replace("/(\r\n|\r|\n)/u", " ", $str));
    //$str = preg_replace("/S+\s+/", ' ', preg_replace("/(\r\n|\r|\n)/", ' ', $str));

    if (iconv_strlen($str) <= $n)
    {
        return $str;
    }
                                    
    $out = "";
    foreach (explode(' ', trim($str)) as $val)
    {
        $out .= $val.' ';            
        if (iconv_strlen($out) >= $n)
        {
            return trim($out).$end_char;
        }        
    }
}


Messages In This Thread
not correct work of the function character_limiter for not latin symbols - by El Forum - 10-07-2008, 06:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB