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-2.1.1 template/wordpress/code/util.php
edge_framework-2.1.0 template/wordpress/code/util.php
edge_framework-2.0.0 template/wordpress/code/util.php
edge_framework-2.0.0.a template/wordpress/code/util.php
edge_framework-1.4.1 template/wordpress/code/util.php
edge_framework-1.4.0 template/wordpress/code/util.php
edge_framework-1.3.6 template/wordpress/code/util.php
edge_framework-1.3.5 template/wordpress/code/util.php
edge_framework-1.3.3 template/wordpress/code/util.php
edge_framework-1.3.2 template/wordpress/code/util.php
edge_framework-1.3.1 template/wordpress/code/util.php
edge_framework-1.3.0 template/wordpress/code/util.php
edge_framework-1.2.9 template/wordpress/code/util.php
edge_framework-1.2.7 template/wordpress/code/util.php
edge_framework-1.2.6 template/wordpress/code/util.php
edge_framework-1.2.5 template/wordpress/code/util.php
edge_framework-1.2.4 template/wordpress/code/util.php
edge_framework-1.2.3 template/wordpress/code/util.php
edge_framework-1.2.2 template/wordpress/code/util.php
edge_framework-1.2.1 template/wordpress/code/util.php