public function substring($text, $searchword, $length = 200)
    {
        $textlen = AnHelperString::strlen($text);
        $lsearchword = AnHelperString::strtolower($searchword);
        $wordfound = false;
        $pos = 0;

        while ($wordfound === false && $pos < $textlen) {
            if (($wordpos = @AnHelperString::strpos($text, ' ', $pos + $length)) !== false) {
                $chunk_size = $wordpos - $pos;
            } else {
                $chunk_size = $length;
            }

            $chunk = AnHelperString::substr($text, $pos, $chunk_size);
            $wordfound = AnHelperString::strpos(AnHelperString::strtolower($chunk), $lsearchword);

            if ($wordfound === false) {
                $pos += $chunk_size + 1;
            }
        }//while

        if ($wordfound !== false) {
            return (($pos > 0) ? '...&nbsp;' : '').$chunk.'&nbsp;...';
        } else {
            if (($wordpos = @AnHelperString::strpos($text, ' ', $length)) !== false) {
                return AnHelperString::substr($text, 0, $wordpos).'&nbsp;...';
            } else {
                return AnHelperString::substr($text, 0, $length);
            }
        }
    }