Test

A paragraph can be truncated in php by following procedures:

Call a function -> truncate_string($string, length);

function truncate_string($data, $max)
    {
//String truncated by '.'
      $val=explode('.',$data);
      if(count($val)>1)
      {
      $max=2;
      $re = "^s*[^.?!]+[.?!]+s*";
        $out = "";
        for($i = 0; $i < $max; $i++) {
            if(ereg($re, $data, $match)) {
                //if a sentence is found, take it out of $data and add it to $out
                $out .= $match[0];
                $data = ereg_replace($re, "", $data);
            }
            else {
                $i = $max;
            }
        }
        
        return $out;
    
        }else
        {
  //truncate by words, call another function 
         $word=truncate_words($data);
         return $word;
        }
        
    }// function for truncate by words     
    function truncate_words($data)
    {
      $str=preg_replace('/s+?(S+)?$/', '', substr($data, 0,200));
      return $str;
    }

have a nice teaser of long string body.