array_diff_key

PHP -> Funkcie -> Array funkcie -> array_diff_key

Syntax

array array_diff_key ( array array1, array array2 [, array ...] )

Popis

Príkaz jazyka PHP
Computes the difference of arrays using keys for comparison.

array_diff_key() returns an array containing all the values of array1 that have keys that are not present in any of the other arguments. Note that the associativity is preserved. This function is like array_diff() except the comparison is done on the keys instead of the values.

Príklad

<?php
$array1 = array('blue'  => 1, 'red'  => 2, 'green'  => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan'  => 8);

var_dump(array_diff_key($array1, $array2));

/*příklad vypíše:
array(2) {
  ["red"]=>
  int(2)
  ["purple"]=>
  int(4)
}
*/

?>