Word count like function Ver.1.0! This function can count your input text

Posted on Aug 23, 2011 in PHP
Word count like function Ver.1.0! This function can count your input text
and display only part of it (like a description) without cutting words in half

  function smart_text ($text_input_var[string] ,text_length[int]) 
  { 
      $strip_content=stripslashes($content); 
      $all_content=strlen("$strip_content"); 

      $standard_content=substr($strip_content ,$text_length); 
      $compare=stristr($standard_content ," "); 
      $minus_content=strlen("$compare"); 
                 
      $result_content=$all_content-$minus_content; 
      $display_content=substr($strip_content ,0, $result_content); 
                 
      $striped_content=stripslashes($display_content);   
      echo nl2br($striped_content); 
  } 

For example i insert a 300 words test but only want about 3 rows of it to be displayed 
without cutting words in half. 
                 
function smart_text($text,200) 

Displayed result will be the first 200 letters of the text plus the letters till the first space 
char.