/** This two functions released under GPL v2, or later at your option */ /** ///FIXME the documantation needs to be fix This function cuts a string at word boundary */ function charCut( $str, $cnt ) { $tryRet = $ret = ''; $a = preg_split( ',\s+,', $str, -1, PREG_SPLIT_NO_EMPTY ); foreach( $a as $w ) { $tryRet .= $w.' '; if ( mb_strlen( $tryRet ) > $cnt ) return rtrim( $ret ); $ret = $tryRet; } return $ret; } /** ///FIXME the documantation needs to be fix This function cuts a string at word boundary */ function wordCut( $str, $cnt ) { return implode(' ', array_slice( preg_split( ',\s+,', $str, -1, PREG_SPLIT_NO_EMPTY ), 0, $cnt)); }