Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

array_keys(3) [php man page]

ARRAY_KEYS(3)								 1							     ARRAY_KEYS(3)

array_keys - Return all the keys or a subset of the keys of an array

SYNOPSIS
array array_keys (array $array, [mixed $search_value], [bool $strict = false]) DESCRIPTION
array_keys(3) returns the keys, numeric and string, from the $array. If the optional $search_value is specified, then only the keys for that value are returned. Otherwise, all the keys from the $array are returned. PARAMETERS
o $array - An array containing keys to return. o $search_value - If specified, then only keys containing these values are returned. o $strict - Determines if strict comparison (===) should be used during the search. RETURN VALUES
Returns an array of all the keys in $array. EXAMPLES
Example #1 array_keys(3) example <?php $array = array(0 => 100, "color" => "red"); print_r(array_keys($array)); $array = array("blue", "red", "green", "blue", "blue"); print_r(array_keys($array, "blue")); $array = array("color" => array("blue", "red", "green"), "size" => array("small", "medium", "large")); print_r(array_keys($array)); ?> The above example will output: Array ( [0] => 0 [1] => color ) Array ( [0] => 0 [1] => 3 [2] => 4 ) Array ( [0] => color [1] => size ) SEE ALSO
array_values(3), array_key_exists(3), array_search(3). PHP Documentation Group ARRAY_KEYS(3)

Check Out this Related Man Page

ARRAY_DIFF_ASSOC(3)							 1						       ARRAY_DIFF_ASSOC(3)

array_diff_assoc - Computes the difference of arrays with additional index check

SYNOPSIS
array array_diff_assoc (array $array1, array $array2, [array $...]) DESCRIPTION
Compares $array1 against $array2 and returns the difference. Unlike array_diff(3) the array keys are also used in the comparison. PARAMETERS
o $array1 - The array to compare from o $array2 - An array to compare against o $... - More arrays to compare against RETURN VALUES
Returns an array containing all the values from $array1 that are not present in any of the other arrays. EXAMPLES
Example #1 array_diff_assoc(3) example In this example you see the "a" => "green" pair is present in both arrays and thus it is not in the output from the function. Unlike this, the pair 0 => "red" is in the output because in the second argument "red" has key which is 1. <?php $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> The above example will output: Array ( [b] => brown [c] => blue [0] => red ) Example #2 array_diff_assoc(3) example Two values from key => value pairs are considered equal only if (string) $elem1 === (string) $elem2 . In other words a strict check takes place so the string representations must be the same. <?php $array1 = array(0, 1, 2); $array2 = array("00", "01", "2"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> The above example will output: Array ( [0] => 0 [1] => 1 ) NOTES
Note This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using, for example, array_diff_assoc($array1[0], $array2[0]);. Note Ensure you pass arguments in the correct order when comparing similar arrays with more keys. The new array should be the first in the list. SEE ALSO
array_diff(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_intersect(3), array_intersect_assoc(3). PHP Documentation Group ARRAY_DIFF_ASSOC(3)
Man Page