summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/general/helpers.rst
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2011-10-06 00:22:53 +0200
committerDerek Jones <derek.jones@ellislab.com>2011-10-06 00:22:53 +0200
commita1360ef24fff8b57353db32ad6045969af28e5d5 (patch)
tree6646e2ccd20a75af67adbb4c8fe1d53d4c6c5ff1 /user_guide_src/source/general/helpers.rst
parent129c181c99848ae14c7edbbaeb7d0bf78ac2db55 (diff)
fixing code spacing in Profiling, Models, Managing Apps, Hooks, and Helpers general docs
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
-----------------------