From b8c283a695c8074a57d8c3dfa00934312638931d Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 19 Jul 2013 16:02:53 -0700 Subject: Dropping unecessary php: directive to function definitions in user guide --- user_guide_src/source/helpers/array_helper.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'user_guide_src/source/helpers/array_helper.rst') diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 9435b3ac7..90ead2942 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -19,7 +19,7 @@ The following functions are available: element() ========= -.. php:function:: element($item, $array, $default = NULL) +.. function:: element($item, $array, $default = NULL) :param string $item: Item to fetch from the array :param array $array: Input array @@ -39,13 +39,13 @@ Example:: 'size' => '' ); - echo element('color', $array); // returns "red" - echo element('size', $array, 'foobar'); // returns "foobar" + echo element('color', $array); // returns "red" + echo element('size', $array, 'foobar'); // returns "foobar" elements() ========== -.. php:function:: elements($items, $array, $default = NULL) +.. function:: elements($items, $array, $default = NULL) :param string $item: Item to fetch from the array :param array $array: Input array @@ -55,7 +55,7 @@ elements() Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist it is set to NULL, or whatever you've specified as the default value via -the third parameter. +the third parameter. Example:: @@ -106,7 +106,7 @@ updated. random_element() ================ -.. php:function:: random_element($array) +.. function:: random_element($array) :param array $array: Input array :returns: string (a random element from the array) -- cgit v1.2.3-24-g4f1b From e07b4e7e6c26e3aa5c4c8e57b2842e1ba818517e Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 19 Jul 2013 16:14:38 -0700 Subject: Updating Array Helper docs --- user_guide_src/source/helpers/array_helper.rst | 141 +++++++++++++------------ 1 file changed, 72 insertions(+), 69 deletions(-) (limited to 'user_guide_src/source/helpers/array_helper.rst') diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 90ead2942..20f5864a6 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -5,7 +5,12 @@ Array Helper The Array Helper file contains functions that assist in working with arrays. -.. contents:: Page Contents +.. contents:: + :local: + +.. raw:: html + +
Loading this Helper =================== @@ -14,114 +19,112 @@ This helper is loaded using the following code:: $this->load->helper('array'); + +Available Functions +=================== + The following functions are available: -element() -========= -.. function:: element($item, $array, $default = NULL) +.. function:: element($item, $array[, $default = NULL]) :param string $item: Item to fetch from the array :param array $array: Input array :param bool $default: What to return if the array isn't valid :returns: NULL on failure or the array item. -Lets you fetch an item from an array. The function tests whether the -array index is set and whether it has a value. If a value exists it is -returned. If a value does not exist it returns NULL, or whatever you've -specified as the default value via the third parameter. + Lets you fetch an item from an array. The function tests whether the + array index is set and whether it has a value. If a value exists it is + returned. If a value does not exist it returns NULL, or whatever you've + specified as the default value via the third parameter. -Example:: + Example:: - $array = array( - 'color' => 'red', - 'shape' => 'round', - 'size' => '' - ); + $array = array( + 'color' => 'red', + 'shape' => 'round', + 'size' => '' + ); - echo element('color', $array); // returns "red" - echo element('size', $array, 'foobar'); // returns "foobar" + echo element('color', $array); // returns "red" + echo element('size', $array, 'foobar'); // returns "foobar" -elements() -========== -.. function:: elements($items, $array, $default = NULL) +.. function:: elements($items, $array[, $default = NULL]) :param string $item: Item to fetch from the array :param array $array: Input array :param bool $default: What to return if the array isn't valid :returns: NULL on failure or the array item. -Lets you fetch a number of items from an array. The function tests -whether each of the array indices is set. If an index does not exist it -is set to NULL, or whatever you've specified as the default value via -the third parameter. + Lets you fetch a number of items from an array. The function tests + whether each of the array indices is set. If an index does not exist it + is set to NULL, or whatever you've specified as the default value via + the third parameter. -Example:: + Example:: - $array = array( - 'color' => 'red', - 'shape' => 'round', - 'radius' => '10', - 'diameter' => '20' - ); + $array = array( + 'color' => 'red', + 'shape' => 'round', + 'radius' => '10', + 'diameter' => '20' + ); - $my_shape = elements(array('color', 'shape', 'height'), $array); + $my_shape = elements(array('color', 'shape', 'height'), $array); -The above will return the following array:: + The above will return the following array:: - array( - 'color' => 'red', - 'shape' => 'round', - 'height' => NULL - ); + array( + 'color' => 'red', + 'shape' => 'round', + 'height' => NULL + ); -You can set the third parameter to any default value you like. -:: + You can set the third parameter to any default value you like. + :: - $my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar'); + $my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar'); -The above will return the following array:: + The above will return the following array:: - array(      - 'color' => 'red', - 'shape' => 'round', - 'height' => 'foobar' - ); + array(      + 'color' => 'red', + 'shape' => 'round', + 'height' => 'foobar' + ); -This is useful when sending the ``$_POST`` array to one of your Models. -This prevents users from sending additional POST data to be entered into -your tables. + This is useful when sending the ``$_POST`` array to one of your Models. + This prevents users from sending additional POST data to be entered into + your tables. -:: + :: - $this->load->model('post_model'); - $this->post_model->update( - elements(array('id', 'title', 'content'), $_POST) - ); + $this->load->model('post_model'); + $this->post_model->update( + elements(array('id', 'title', 'content'), $_POST) + ); -This ensures that only the id, title and content fields are sent to be -updated. + This ensures that only the id, title and content fields are sent to be + updated. -random_element() -================ .. function:: random_element($array) :param array $array: Input array :returns: string (a random element from the array) -Takes an array as input and returns a random element from it. + Takes an array as input and returns a random element from it. -Usage example:: + Usage example:: - $quotes = array( - "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", - "Don't stay in bed, unless you can make money in bed. - George Burns", - "We didn't lose the game; we just ran out of time. - Vince Lombardi", - "If everything seems under control, you're not going fast enough. - Mario Andretti", - "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein", - "Chance favors the prepared mind - Louis Pasteur" - ); + $quotes = array( + "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson", + "Don't stay in bed, unless you can make money in bed. - George Burns", + "We didn't lose the game; we just ran out of time. - Vince Lombardi", + "If everything seems under control, you're not going fast enough. - Mario Andretti", + "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein", + "Chance favors the prepared mind - Louis Pasteur" + ); - echo random_element($quotes); \ No newline at end of file + echo random_element($quotes); \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3de130c2da3b93a3404f264e92d7b65354de3548 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 7 Feb 2014 23:31:49 +0200 Subject: [ci skip] Add return types to helper docs (+ some other formatting) --- user_guide_src/source/helpers/array_helper.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/helpers/array_helper.rst') diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 20f5864a6..4805f581a 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -32,6 +32,7 @@ The following functions are available: :param array $array: Input array :param bool $default: What to return if the array isn't valid :returns: NULL on failure or the array item. + :rtype: mixed Lets you fetch an item from an array. The function tests whether the array index is set and whether it has a value. If a value exists it is @@ -56,6 +57,7 @@ The following functions are available: :param array $array: Input array :param bool $default: What to return if the array isn't valid :returns: NULL on failure or the array item. + :rtype: mixed Lets you fetch a number of items from an array. The function tests whether each of the array indices is set. If an index does not exist it @@ -112,7 +114,8 @@ The following functions are available: .. function:: random_element($array) :param array $array: Input array - :returns: string (a random element from the array) + :returns: A random element from the array + :rtype: mixed Takes an array as input and returns a random element from it. -- cgit v1.2.3-24-g4f1b