element($item, $array[, $default = NULL])
| Parameters: |
|
|---|---|
| Returns: |
NULL on failure or the array item. |
| Return type: |
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 returned. If a value does not exist it returns NULL, or whatever you’ve specified as the default value via the third parameter.
Example:
$array = array(
'color' => 'red',
'shape' => 'round',
'size' => ''
);
echo element('color', $array); // returns "red"
echo element('size', $array, 'foobar'); // returns "foobar"
Please login to continue.