Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

array_pop(3) [php man page]

ARRAY_POP(3)								 1							      ARRAY_POP(3)

array_pop - Pop the element off the end of array

SYNOPSIS
mixed array_pop (array &$array) DESCRIPTION
array_pop(3) pops and returns the last value of the $array, shortening the $array by one element. Note This function will reset(3) the array pointer of the input array after use. PARAMETERS
o $array - The array to get the value from. RETURN VALUES
Returns the last value of $array. If $array is empty (or is not an array), NULL will be returned. ERRORS
/EXCEPTIONS This function will produce an error of level E_WARNING when called on a non-array. EXAMPLES
Example #1 array_pop(3) example <?php $stack = array("orange", "banana", "apple", "raspberry"); $fruit = array_pop($stack); print_r($stack); ?> After this, $stack will have only 3 elements: Array ( [0] => orange [1] => banana [2] => apple ) and raspberry will be assigned to $fruit. SEE ALSO
array_push(3), array_shift(3), array_unshift(3). PHP Documentation Group ARRAY_POP(3)

Check Out this Related Man Page

ARRAY_WALK(3)								 1							     ARRAY_WALK(3)

array_walk - Apply a user supplied function to every member of an array

SYNOPSIS
bool array_walk NULL (array &$array, callable $callback, [mixed $userdata]) DESCRIPTION
Applies the user-defined $callback function to each element of the $array array. array_walk(3) is not affected by the internal array pointer of $array. array_walk(3) will walk through the entire array regardless of pointer position. PARAMETERS
o $array - The input array. o $callback - Typically, $callback takes on two parameters. The $array parameter's value being the first, and the key/index second. Note If $callback needs to be working with the actual values of the array, specify the first parameter of $callback as a refer- ence. Then, any changes made to those elements will be made in the original array itself. Note Many internal functions (for example strtolower(3)) will throw a warning if more than the expected number of argument are passed in and are not usable directly as a $callback. Only the values of the $array may potentially be changed; its structure cannot be altered, i.e., the programmer cannot add, unset or reorder elements. If the callback does not respect this requirement, the behavior of this function is undefined, and unpre- dictable. o $userdata - If the optional $userdata parameter is supplied, it will be passed as the third parameter to the $callback. RETURN VALUES
Returns TRUE on success or FALSE on failure. ERRORS
/EXCEPTIONS If function $callback requires more parameters than given to it, an error of level E_WARNING will be generated each time array_walk(3) calls $callback. EXAMPLES
Example #1 array_walk(3) example <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); function test_alter(&$item1, $key, $prefix) { $item1 = "$prefix: $item1"; } function test_print($item2, $key) { echo "$key. $item2<br /> "; } echo "Before ...: "; array_walk($fruits, 'test_print'); array_walk($fruits, 'test_alter', 'fruit'); echo "... and after: "; array_walk($fruits, 'test_print'); ?> The above example will output: Before ...: d. lemon a. orange b. banana c. apple d. fruit: lemon a. fruit: orange b. fruit: banana c. fruit: apple SEE ALSO
array_walk_recursive(3), iterator_apply(3), list(3), each(3), call_user_func_array(3), array_map(3), information about the callback type, foreach. PHP Documentation Group ARRAY_WALK(3)
Man Page