bratsun
9/8/2014 - 7:07 AM

Word trim

Word trim

// word trim function

function word_trim($string, $count, $ellipsis = FALSE){  $words = explode(' ', $string);  if (count($words) > $count){    array_splice($words, $count);    $string = implode(' ', $words);    if (is_string($ellipsis)){      $string .= $ellipsis;    }    elseif ($ellipsis){      $string .= '…';    }  }  return $string;}