skt_pathway_string_limit_words

The SKT Pathway skt pathway string limit words function.

Description

skt_pathway_string_limit_words( $string, $word_limit ); 

Parameters (2)

0. $string
The string.
1. $word_limit
The word limit.

Usage

  1. if ( !function_exists( 'skt_pathway_string_limit_words' ) ) { 
  2. require_once '/inc/custom-functions.php'; 
  3.  
  4. // The string. 
  5. $string = null; 
  6.  
  7. // The word limit. 
  8. $word_limit = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = skt_pathway_string_limit_words($string, $word_limit); 
  12.  

Defined (1)

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

/inc/custom-functions.php  
  1. function skt_pathway_string_limit_words($string, $word_limit) { 
  2. $words = explode(' ', $string, ($word_limit + 1)); 
  3. if(count($words) > $word_limit) 
  4. array_pop($words); 
  5. return implode(' ', $words);