diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 075a31fdf08..7f87f0d0c1c 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -115,5 +115,43 @@ function elements($items, $array, $default = FALSE) } } +// -------------------------------------------------------------------- + +/** + * Array to string - Join array elements with a string. + * + * @access public + * @param array + * @param string + * @param string + * @return string + */ +if ( ! function_exists('array_to_str')) +{ + function array_to_str($array, $sep = ', ', $sep_last = '') + { + $return = ''; + + if ( ! $array) + { + return ''; + } + + if ($sep_last) + { + $last_element = array_pop($array); + + if ( ! count($array)) + { + return $last_element; + } + + return implode($sep, $array).$sep_last.$last_element; + } + + return implode($sep, $array); + } +} + /* End of file array_helper.php */ /* Location: ./system/helpers/array_helper.php */ \ No newline at end of file