From 269b942a2bf7b022795e591d9b0ad04526ee7e09 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Mon, 28 Jan 2008 21:00:20 +0000 Subject: added ability to "extend" helpers * modified Loader to check for prefixed helpers in application/helpers folder * surrounded provided helper functions with if (! function_exists('foo')) conditionals so the user's helper functions take precedent. --- system/helpers/array_helper.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'system/helpers/array_helper.php') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 85d03794c..236e3904e 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -39,14 +39,17 @@ * @param mixed * @return mixed depends on what the array contains */ -function element($item, $array, $default = FALSE) +if (! function_exists('element')) { - if ( ! isset($array[$item]) OR $array[$item] == "") + function element($item, $array, $default = FALSE) { - return $default; - } + if ( ! isset($array[$item]) OR $array[$item] == "") + { + return $default; + } - return $array[$item]; + return $array[$item]; + } } // ------------------------------------------------------------------------ @@ -58,14 +61,16 @@ function element($item, $array, $default = FALSE) * @param array * @return mixed depends on what the array contains */ -function random_element($array) +if (! function_exists('random_element')) { - if ( ! is_array($array)) + function random_element($array) { - return $array; - } - return $array[array_rand($array)]; + if ( ! is_array($array)) + { + return $array; + } + return $array[array_rand($array)]; + } } - ?> \ No newline at end of file -- cgit v1.2.3-24-g4f1b