php man page for array_intersect_key

Query: array_intersect_key

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

ARRAY_INTERSECT_KEY(3)							 1						    ARRAY_INTERSECT_KEY(3)

array_intersect_key - Computes the intersection of arrays using keys for comparison

SYNOPSIS
array array_intersect_key (array $array1, array $array2, [array $...])
DESCRIPTION
array_intersect_key(3) returns an array containing all the entries of $array1 which have keys that are present in all the arguments.
PARAMETERS
o $array1 - The array with master keys to check. o $array2 - An array to compare keys against. o $... - A variable list of arrays to compare.
RETURN VALUES
Returns an associative array containing all the entries of $array1 which have keys that are present in all arguments.
EXAMPLES
Example #1 array_intersect_key(3) example <?php $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4); $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); var_dump(array_intersect_key($array1, $array2)); ?> The above example will output: array(2) { ["blue"]=> int(1) ["green"]=> int(3) } In our example you see that only the keys 'blue' and 'green' are present in both arrays and thus returned. Also notice that the values for the keys 'blue' and 'green' differ between the two arrays. A match still occurs because only the keys are checked. The values returned are those of $array1. The two keys from the key => value pairs are considered equal only if (string) $key1 === (string) $key2 . In other words a strict type check is executed so the string representation must be the same.
SEE ALSO
array_diff(3), array_udiff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_diff_key(3), array_diff_ukey(3), array_intersect(3), array_intersect_assoc(3), array_intersect_uassoc(3), array_intersect_ukey(3). PHP Documentation Group ARRAY_INTERSECT_KEY(3)
Related Man Pages
array_diff_key(3) - php
array_intersect_assoc(3) - php
wincache_ucache_get(3) - php
array_diff_uassoc(3) - php
array_udiff_uassoc(3) - php
Similar Topics in the Unix Linux Community
Comma Seperated List of Values
Parameter Problem With an Array Variable
perl array help !
Modifying the values of dynamically named arrays
Compare bash arrays issue