جزاكم الله خيراً إخواني ..
كنت قد برمجت دالة في احدى المرات ، سوف أجلبها لكم ممكن تستفيدوا منها .. تفضلوا :
	كود PHP:
	
    function cutstr($str,$num,$cutwords=0,$cutby=1,$dotsatend=1) {
        // note that the parameter ($cutwords) is optional & only be actived if the cutting operation is applied on letters not words ..!!
        $originalstr = $str;
        $find = array("/((\<BR\>)+)/si");
        $replace = array(" \\1");
        $str = preg_replace($find,$replace,$str);
        // first , if we want to shorten by words num
        if (($cutby=="2" || $cutby=="words") && $num>0) {
            // split $str into elements in an array by words
            $str = explode(" ",$str);
            // make a counter for words
            $x = 1;
            while (list($a,$b) = each($str)) {
                // add this word to the returned value
                $retval .= $retval == "" ? $b : " ".$b;
                // if this is the last word we'll end this loop
                if ($x==$num) { break; }
                // add 1 to the counter
                $x++;
            }
            // compare between the original string and the returned value to add dots if neccessary
            if ($dotsatend > 0) {
                if ($retval != $originalstr) {
                    $dotnum = 0;
                    $dots = "";
                    while ($dotnum < $dotsatend) {
                        $dots .= ".";
                        $dotnum++;
                    }
                    $retval = $retval . " " . $dots;
                }
            }
            // return the cut part
            return $retval;
        } 
 تحياتي، sBForum