note 99579 modified in function.array-intersect-ukey by danbrown

From: Date: Wed, 25 Aug 2010 14:02:31 +0000
Subject: note 99579 modified in function.array-intersect-ukey by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172053@lists.php.net to get a copy of this message
Using PHP Version 5.2.9-2 on Win 32 For those wondering what happens with numeric keys, here's a short example that might save you time : <?php $a=array(1=>'a',2=>'b',3=>'c'); $b=array(2=>'z',3=>'c',4=>'d'); $c=array_intersect_key($a,$b); print_r($c); ?> Will output Array ( [2] => b [3] => c ) It works fine, if values are different, the first array's ones are retained. --was-- Using PHP Version 5.2.9-2 on Win 32 For those wondering what happens with numeric keys, here's a short example that might save you time : $a=array(1=>'a',2=>'b',3=>'c'); $b=array(2=>'z',3=>'c',4=>'d'); $c=array_intersect_key($a,$b); print_r($c); Will output Array ( [2] => b [3] => c ) It works fine, if values are different, the first array's ones are retained. http://php.net/manual/en/function.array-intersect-ukey.php

« previous php.notes (#172053) next »