Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

each(3) [php man page]

EACH(3) 								 1								   EACH(3)

each - Return the current key and value pair from an array and advance the array cursor

SYNOPSIS
array each (array &$array) DESCRIPTION
Return the current key and value pair from an array and advance the array cursor. After each(3) has executed, the array cursor will be left on the next element of the array, or past the last element if it hits the end of the array. You have to use reset(3) if you want to traverse the array again using each. PARAMETERS
o $array - The input array. RETURN VALUES
Returns the current key and value pair from the array $array. This pair is returned in a four-element array, with the keys 0, 1, key, and value. Elements 0 and key contain the key name of the array element, and 1 and value contain the data. If the internal pointer for the array points past the end of the array contents, each(3) returns FALSE. EXAMPLES
Example #1 each(3) examples <?php $foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese"); $bar = each($foo); print_r($bar); ?> $bar now contains the following key/value pairs: Array ( [1] => bob [value] => bob [0] => 0 [key] => 0 ) <?php $foo = array("Robert" => "Bob", "Seppo" => "Sepi"); $bar = each($foo); print_r($bar); ?> $bar now contains the following key/value pairs: Array ( [1] => Bob [value] => Bob [0] => Robert [key] => Robert ) each(3) is typically used in conjunction with list(3) to traverse an array, here's an example: Example #2 Traversing an array with each(3) <?php $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry'); reset($fruit); while (list($key, $val) = each($fruit)) { echo "$key => $val "; } ?> The above example will output: a => apple b => banana c => cranberry Caution Because assigning an array to another variable resets the original array's pointer, our example above would cause an endless loop had we assigned $fruit to another variable inside the loop. Warning each(3) will also accept objects, but may return unexpected results. It's therefore not recommended to iterate though object proper- ties with each(3). SEE ALSO
key(3), list(3), current(3), reset(3), next(3), prev(3), foreach, Object Iteration. PHP Documentation Group EACH(3)

Check Out this Related Man Page

WINCACHE_UCACHE_DELETE(3)						 1						 WINCACHE_UCACHE_DELETE(3)

wincache_ucache_delete - Deletes variables from the user cache

SYNOPSIS
bool wincache_ucache_delete (mixed $key) DESCRIPTION
Deletes the elements in the user cache pointed by $key. PARAMETERS
o $key - The $key that was used to store the variable in the cache. $key is case sensitive. $key can be an array of keys. RETURN VALUES
Returns TRUE on success or FALSE on failure. If $key is an array then the function returns FALSE if every element of the array fails to get deleted from the user cache, otherwise returns an array which consists of all the keys that are deleted. EXAMPLES
Example #1 Using wincache_ucache_delete(3) with $key as a string <?php wincache_ucache_set('foo', 'bar'); var_dump(wincache_ucache_delete('foo')); var_dump(wincache_ucache_exists('foo')); ?> The above example will output: bool(true) bool(false) Example #2 Usingwincache_ucache_delete(3) with $key as an array <?php $array1 = array('green' => '5', 'blue' => '6', 'yellow' => '7', 'cyan' => '8'); wincache_ucache_set($array1); $array2 = array('green', 'blue', 'yellow', 'cyan'); var_dump(wincache_ucache_delete($array2)); ?> The above example will output: array(4) { [0]=> string(5) "green" [1]=> string(4) "Blue" [2]=> string(6) "yellow" [3]=> string(4) "cyan" } Example #3 Using wincache_ucache_delete(3) with $key as an array where some elements cannot be deleted <?php $array1 = array('green' => '5', 'blue' => '6', 'yellow' => '7', 'cyan' => '8'); wincache_ucache_set($array1); $array2 = array('orange', 'red', 'yellow', 'cyan'); var_dump(wincache_ucache_delete($array2)); ?> The above example will output: array(2) { [0]=> string(6) "yellow" [1]=> string(4) "cyan" } SEE ALSO
wincache_ucache_set(3), wincache_ucache_add(3), wincache_ucache_get(3), wincache_ucache_clear(3), wincache_ucache_exists(3), win- cache_ucache_meminfo(3), wincache_ucache_info(3). PHP Documentation Group WINCACHE_UCACHE_DELETE(3)
Man Page