From a1360ef24fff8b57353db32ad6045969af28e5d5 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 5 Oct 2011 17:22:53 -0500 Subject: fixing code spacing in Profiling, Models, Managing Apps, Hooks, and Helpers general docs --- user_guide_src/source/general/helpers.rst | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/general/helpers.rst') 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 ----------------------- -- cgit v1.2.3-24-g4f1b