From 0cd553566578dd4c23e1541fc837901bdfefa831 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 2 Jul 2012 15:20:42 +0200 Subject: Update Array Helper documentation default value of the "default value" parameter has changed in element() and elements() methods --- user_guide_src/source/helpers/array_helper.rst | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst index 4308753bb..15b5e17c4 100644 --- a/user_guide_src/source/helpers/array_helper.rst +++ b/user_guide_src/source/helpers/array_helper.rst @@ -21,17 +21,17 @@ The following functions are available: element() ========= -.. php:method:: element($item, $array, $default = FALSE) +.. php:method:: element($item, $array, $default = NULL) :param string $item: Item to fetch from the array :param array $array: Input array :param boolean $default: What to return if the array isn't valid - :returns: FALSE on failure or the array item. + :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 FALSE, or whatever you've +returned. If a value does not exist it returns NULL, or whatever you've specified as the default value via the third parameter. Example :: @@ -43,31 +43,31 @@ specified as the default value via the third parameter. Example ); echo element('color', $array); // returns "red" - echo element('size', $array, NULL); // returns NULL + echo element('size', $array, 'foobar'); // returns "foobar" 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 FALSE, or whatever you've specified as the default value via +is set to NULL, or whatever you've specified as the default value via the third parameter. -.. php:method:: elements($items, $array, $default = FALSE) +.. php:method:: elements($items, $array, $default = NULL) :param string $item: Item to fetch from the array :param array $array: Input array :param boolean $default: What to return if the array isn't valid - :returns: FALSE on failure or the array item. + :returns: NULL on failure or the array item. Example :: $array = array( - 'color' => 'red',   - 'shape' => 'round',      - 'radius' => '10',      + 'color' => 'red', + 'shape' => 'round', + 'radius' => '10', 'diameter' => '20' ); @@ -78,25 +78,25 @@ The above will return the following array :: array( - 'color' => 'red',      - 'shape' => 'round',      - 'height' => FALSE + 'color' => 'red', + 'shape' => 'round', + 'height' => NULL ); You can set the third parameter to any default value you like :: - $my_shape = elements(array('color', 'shape', 'height'), $array, NULL); + $my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar'); The above will return the following array :: array(      - 'color' => 'red',      - 'shape' => 'round',      - 'height' => NULL + 'color' => 'red', + 'shape' => 'round', + 'height' => 'foobar' ); This is useful when sending the $_POST array to one of your Models. -- cgit v1.2.3-24-g4f1b