note 24545 added to function.array-keys

From: Date: Wed, 21 Aug 2002 03:05:08 +0000
Subject: note 24545 added to function.array-keys
Groups: php.notes 
Request: Send a blank email to php-notes+get-35289@lists.php.net to get a copy of this message
Here is a way to use array_intersect on array keys rather than values: $a = array("apple" => "red", "banana" => "yellow"); $z = array("apple" => "green", "peach" => "orange", "banana" => "rotten"); $intersected_keys = array_intersect(array_keys($a), array_keys($z)); print_r($intersected_keys); This will print: Array ( [0] => apple [1] => banana ) -- http://www.php.net/manual/en/function.array-keys.php http://master.php.net/manage/user-notes.php?action=edit+24545 http://master.php.net/manage/user-notes.php?action=delete+24545 http://master.php.net/manage/user-notes.php?action=reject+24545

« previous php.notes (#35289) next »