# ket tomb kulcs alapu metszetet szamitja ki, az erteken is ellenorzest vegez
#
# calculating (key base) intersection of arrays (value are checked)
# use: $result_array = array_intersect_assoc($a1, $a2, $a3,..);
#
##
# original code by [jochem at iamjochem dawt com] : array_diff_keys()
<?php
function array_intersect_assoc() {
$args = func_get_args();
$res = $args[0];
for ($i=1;$i<count($args);$i++) {
if (!is_array($args[$i])) {continue;}
foreach ($res as $key => $data) {
if ( (!array_key_exists($key, $args[$i])) || ( (isset($args[$i][$key])) && ($args[$i][$key] !== $res[$key]) ) ) {
unset($res[$key]);
}
}
}
return $res;
}
?>
<?php
$array1 = array("a"=>"green", "b"=>"brown", "c"=>"blue", "red");
$array2 = array("a"=>"green", "b"=>"yellow", "c"=>"yellow", "red");
$a = array('a'=>'green', 'b'=>'brown', 'c'=>'yellow');
$b = array('a'=>'green', 'b'=>'brown', 'c'=>'yellow', 'e'=>'yellow');
$result_array = array_intersect_assoc($a, $b, $array1, $array2);
?>
$args array will look like:
(
0 =>
(
a => green
b => brown
c => yellow
)
1 =>
(
a => green
b => brown
c => yellow
e => yellow
)
2 =>
(
a => green
b => brown
c => blue
0 => red
)
3 =>
(
a => green
b => yellow
c => yellow
0 => red
)
)
$result_array will look like:
(
a => green
)