summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/general/helpers.rst
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/general/helpers.rst')
-rw-r--r--user_guide_src/source/general/helpers.rst23
1 files changed, 22 insertions, 1 deletions
diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst
index 2b113c1f4..71cb8b25a 100644
--- a/user_guide_src/source/general/helpers.rst
+++ b/user_guide_src/source/general/helpers.rst
@@ -102,7 +102,28 @@ For example, to extend the native Array Helper you'll create a file
named application/helpers/MY_array_helper.php, and add or override
functions::
- // any_in_array() is not in the Array Helper, so it defines a new function function any_in_array($needle, $haystack) {     $needle = (is_array($needle)) ? $needle : array($needle);     foreach ($needle as $item)     {         if (in_array($item, $haystack))         {             return TRUE;         }         }     return FALSE; } // random_element() is included in Array Helper, so it overrides the native function function random_element($array) {     shuffle($array);     return array_pop($array); }
+ // any_in_array() is not in the Array Helper, so it defines a new function
+ function any_in_array($needle, $haystack)
+ {
+ $needle = (is_array($needle)) ? $needle : array($needle);
+
+ foreach ($needle as $item)
+ {
+ if (in_array($item, $haystack))
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+
+ // random_element() is included in Array Helper, so it overrides the native function
+ function random_element($array)
+ {
+ shuffle($array);
+ return array_pop($array);
+ }
Setting Your Own Prefix
-----------------------