pmpro_implodeToEnglish

The Paid Memberships Pro pmpro implodeToEnglish function.

Description

pmpro_implodeToEnglish( $array, (string) $conjunction = 'and' ); 

Parameters (2)

0. $array
The array.
1. $conjunction — Optional. (string) => 'and'
The conjunction.

Usage

  1. if ( !function_exists( 'pmpro_implodeToEnglish' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The array. 
  5. $array = null; 
  6.  
  7. // The conjunction. 
  8. $conjunction = 'and'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pmpro_implodeToEnglish($array, $conjunction); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_implodeToEnglish($array, $conjunction = 'and') 
  2. // sanity check 
  3. if (!$array || !count ($array)) 
  4. return ''; 
  5.  
  6. // get last element 
  7. $last = array_pop ($array); 
  8.  
  9. // if it was the only element - return it 
  10. if (!count ($array)) 
  11. return $last; 
  12.  
  13. //possibly translate the conjunction 
  14. if($conjunction == 'and') 
  15. $conjunction = __('and', 'paid-memberships-pro' ); 
  16.  
  17. return implode (', ', $array).' ' . $conjunction . ' '.$last;