reduce_multiples()

reduce_multiples($str[, $character = ''[, $trim = FALSE]])

Parameters:
  • $str (string) – Text to search in
  • $character (string) – Character to reduce
  • $trim (bool) – Whether to also trim the specified character
Returns:

Reduced string

Return type:

string

Reduces multiple instances of a particular character occuring directly after each other. Example:

$string = "Fred, Bill,, Joe, Jimmy";
$string = reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"

If the third parameter is set to TRUE it will remove occurrences of the character at the beginning and the end of the string. Example:

$string = ",Fred, Bill,, Joe, Jimmy,";
$string = reduce_multiples($string, ", ", TRUE); //results in "Fred, Bill, Joe, Jimmy"
doc_CodeIgniter
2016-10-15 16:32:36
Comments
Leave a Comment

Please login to continue.