note 37238 deleted from function.array-intersect-assoc by aidan

From: Date: Sun, 12 Sep 2004 13:28:37 +0000
Subject: note 37238 deleted from function.array-intersect-assoc by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76523@lists.php.net to get a copy of this message
Note Submitter: mrmachine at nospam dot mrmachine dot net ---- this is a re-implementation of array_intersect_assoc for php4 versions < 4.3.0. this function does not use a strict comparison of values for compatibility with the php 4.3.0 version. <?php function array_intersect_assoc() { $args = func_get_args(); $intersection = array(); foreach ($args[0] as $k => $v) { $intersection[$k] = $v; for ($i = 1; $i < count($args); $i++) { if (!isset($args[$i][$k]) || $args[$i][$k] != $v) { unset($intersection[$k]); break; } } } return $intersection; } $a1 = array(1, 2, 'x' => 3, '10' => 4); $a2 = array(2, 2, 'x' => 3, '10' => 4); $a3 = array(3, 2, 'y' => 3, 10 => '4'); $x = array_intersect_assoc($a1, $a2, $a3); print_r($x); ?>

« previous php.notes (#76523) next »