home/includes/functions.php
/*
     * Function to ellipse-ify text to a specific length
     *
     * @param string $text      The text to be ellipsified
     * @param int    $max       The maximum number of characters (to the word) that should be allowed
     * @param string $append    The text to append to $text
     * @return string           The shortened text
     */
Function to ellipse-ify text to a specific length
@param string $text      The text to be ellipsified
@param int    $max       The maximum number of characters (to the word) that should be allowed
@param string $append    The text to append to $text
@return string           The shortened text
Function to ellipse - ify text to a specific length @param string $text The text to be ellipsified @param int $max The maximum number of characters ( to the word ) that should be allowed @param string $append The text to append to $text @return string The shortened text
function ellipsis($text, $max = '', $append = '&hellip;') {
        if (strlen($text) <= $max) return $text;
        $replacements = array(
            '|<br /><br />|' => ' ',
            '|&nbsp;|' => ' ',
            '|&rsquo;|' => '\'',
            '|&lsquo;|' => '\'',
            '|&ldquo;|' => '"',
            '|&rdquo;|' => '"',
        );
        $patterns = array_keys($replacements);
        $replacements = array_values($replacements);
        $text = preg_replace($patterns, $replacements, $text);
        $text = strip_tags($text);
        $out = substr($text, 0, $max);
        if (strpos($text, ' ') === false) return $out.$append;
        return preg_replace('/(\W)&(\W)/', '$1&amp;$2', (preg_replace('/\W+$/', ' ', preg_replace('/\w+$/', '', $out)))).$append;
    }
function ellipsis ( $ text , $ max = '' , $ append = '&hellip;' ) { if ( strlen ( $ text ) <= $ max ) return $ text ; $ replacements = array ( '|<br /><br />|' => ' ' , '|&nbsp;|' => ' ' , '|&rsquo;|' => '\'' , '|&lsquo;|' => '\'' , '|&ldquo;|' => '"' , '|&rdquo;|' => '"' , ) ; $ patterns = array_keys ( $ replacements ) ; $ replacements = array_values ( $ replacements ) ; $ text = preg_replace ( $ patterns , $ replacements , $ text ) ; $ text = strip_tags ( $ text ) ; $ out = substr ( $ text , 0 , $ max ) ; if ( strpos ( $ text , ' ' ) === false ) return $ out . $ append ; return preg_replace ( '/(\W)&(\W)/' , '$1&amp;$2' , ( preg_replace ( '/\W+$/' , ' ' , preg_replace ( '/\w+$/' , '' , $ out ) ) ) ) . $ append ; }
Function to ellipse-ify text to a specific length
 @param string $text      The text to be ellipsified
 @param int    $max       The maximum number of characters (to the word) that should be allowed
 @param string $append    The text to append to $text
 @return string           The shortened text
Function to ellipse - ify text to a specific length @param string $text The text to be ellipsified @param int $max The maximum number of characters ( to the word ) that should be allowed @param string $append The text to append to $text @return string The shortened text
// Convert double newlines to spaces. // Remove any HTML.  We only want text.