<?
    
function closest_word($sentince$chars 250)
    {
        if (
strlen($sentince) > $chars)
        {
            
$temp substr($sentince0$chars 1);
            for (
$i $chars$i 1$i--)
            {
                if (
substr($temp$i1) == ' ')
                {
                    
$temp substr($temp0$i);
                    for (
$j $i 1$j 1$j--)
                    {
                        if ((
ord(substr($temp$j1)) >= 48 && ord(substr($temp$j1)) <= 57) || (ord(substr($temp$j1)) >= 65 && ord(substr($temp$j1)) <= 122))
                        {
                            
$sentince substr($temp0$j 1) . '...';
                            break;
                        }
                    }
                    break;
                }
            }
        }
        return 
$sentince;
    }
?>