Sha256: b3ac49026ba4b10731f100009ec49e668aa50e71d49b7a2c00778ed8785b8ed8

Contents?: true

Size: 713 Bytes

Versions: 22

Compression:

Stored size: 713 Bytes

Contents

<?php // Generic Utility

/*
  ELLIPSIZE
  - Adding "..." at the end of the string.
  - Default is 160 characters
*/

function ellipsize($text, $char_number = "160", $etc = "...") {
  $text = html_entity_decode($text, ENT_QUOTES);
  if (strlen($text) > $char_number) {
    $text = substr($text, 0, $char_number);
    $text = substr($text,0,strrpos($text," "));

    $punctuation = ".!?:;,-"; // punctuation you want removed

    $text = (strspn(strrev($text),  $punctuation) != 0)
            ?
            substr($text, 0, -strspn(strrev($text),  $punctuation))
            :
            $text;

    $text = $text.$etc;
  }
  $text = htmlentities($text, ENT_QUOTES);
  return $text;
}

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
edge_framework-1.2.0 template/wordpress/code/util.php
edge_framework-1.1.0 template/wordpress/code/util.php