diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-07-02 15:24:17 +0200 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2012-07-02 15:24:17 +0200 |
commit | 1e867f7a7bd80a0fadc597ab0b38fe34f00081ae (patch) | |
tree | 5d6fe41a94c91bdbeb419a878dfe316e5903d57f /user_guide_src | |
parent | ec90216969c2d7bea46a073ecc9c8a95d42f7d92 (diff) | |
parent | 0cd553566578dd4c23e1541fc837901bdfefa831 (diff) |
Merge pull request #1561 from vlakoff/doc
Update Array Helper documentation
Diffstat (limited to 'user_guide_src')
-rw-r--r-- | user_guide_src/source/helpers/array_helper.rst | 34 |
1 files changed, 17 insertions, 17 deletions
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. |