evolve_truncate

The evolve evolve truncate function.

Description

evolve_truncate( $str, (int) $length = 10, (string) $trailing = '..' ); 

Parameters (3)

0. $str
The str.
1. $length — Optional. (int) => 10
The length.
2. $trailing — Optional. (string) => '..'
The trailing.

Usage

  1. if ( !function_exists( 'evolve_truncate' ) ) { 
  2. require_once '/library/functions/basic-functions.php'; 
  3.  
  4. // The str. 
  5. $str = null; 
  6.  
  7. // The length. 
  8. $length = 10; 
  9.  
  10. // The trailing. 
  11. $trailing = '..'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = evolve_truncate($str, $length, $trailing); 
  15.  

Defined (1)

The function is defined in the following location(s).

/library/functions/basic-functions.php  
  1. function evolve_truncate($str, $length = 10, $trailing = '..') { 
  2. $length -= mb_strlen($trailing); 
  3. if (mb_strlen($str) > $length) { 
  4. return mb_substr($str, 0, $length) . $trailing; 
  5. } else { 
  6. $res = $str; 
  7.  
  8. return $res;