note 84659 added to function.array-keys

From: Date: Thu, 24 Jul 2008 07:10:35 +0000
Subject: note 84659 added to function.array-keys
Groups: php.notes 
Request: Send a blank email to php-notes+get-142636@lists.php.net to get a copy of this message
<?php /* * This function will return the keys of elements in the * haystack where the value is found in array needle */ function array_value_intersect_keys( $array_haystack, $array_needle ){ $intersected = array_intersect( $array_haystack, $array_needle ); return array_keys( $intersected ); } // usage $array_haystack = array( 1 => 2, 2 => 5, 'red' => 8, 9 => 14 ); $array_needle = array( 2, 8 ); $array_keys_of_intersecting_values = array_value_intersect_keys( $array_haystack, $array_needle ); print_r( $array_keys_of_intersecting_values ); ?> returns Array ( [0] => 1 [1] => red ) ---- Server IP: 92.48.100.16 Probable Submitter: 82.71.228.44 ---- Manual Page -- http://www.php.net/manual/en/function.array-keys.php Edit -- https://master.php.net/note/edit/84659 Del: integrated -- https://master.php.net/note/delete/84659/integrated Del: useless -- https://master.php.net/note/delete/84659/useless Del: bad code -- https://master.php.net/note/delete/84659/bad+code Del: spam -- https://master.php.net/note/delete/84659/spam Del: non-english -- https://master.php.net/note/delete/84659/non-english Del: in docs -- https://master.php.net/note/delete/84659/in+docs Del: other reasons-- https://master.php.net/note/delete/84659 Reject -- https://master.php.net/note/reject/84659 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#142636) next »