summaryrefslogtreecommitdiffstats
path: root/system/helpers/array_helper.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-01-28 22:00:20 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-01-28 22:00:20 +0100
commit269b942a2bf7b022795e591d9b0ad04526ee7e09 (patch)
treef465bb5a700d4cc5d72ca6e55e251640a46b869b /system/helpers/array_helper.php
parenta25530f6594c7ba45b3faa9537fda9f807069759 (diff)
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.
Diffstat (limited to 'system/helpers/array_helper.php')
-rw-r--r--system/helpers/array_helper.php27
1 files changed, 16 insertions, 11 deletions
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