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

[eluser]emperius[/eluser]
nope

result is the same

Code:
function character_limiter($str, $n = 500, $end_char = '…')
{
    if (iconv_strlen($str) < $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:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB