Posted By

james0rion on 08/10/10


Tagged

truncate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

manavecplan


First Words


 / Published in: PHP
 

  1. function first_words($string, $word_count) {
  2. $array = explode(' ', $string, $word_count+1);
  3. $return = '';
  4. foreach ($array as $k=>$v) {
  5. if ($k < $word_count) $return .= "$v ";
  6. }//end foreach
  7. return $return;
  8. }

Report this snippet  

You need to login to post a comment.