note 24545 deleted from function.array-keys by googleguy

From: Date: Tue, 22 Oct 2013 06:46:04 +0000
Subject: note 24545 deleted from function.array-keys by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196631@lists.php.net to get a copy of this message
Note Submitter: jacob at keystreams dot com ---- Here is a way to use array_intersect on array keys rather than values: <?php $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 )

« previous php.notes (#196631) next »