Edit report at https://bugs.php.net/bug.php?id=64854&edit=1
ID: 64854 Updated by: ni...@php.net Reported by: bensor987 at neuf dot fr Summary: array_key_exists( array('key1', 'key2', 'key3'), $array); -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Arrays related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: For "normal" arrays (with no odd null-value usages), you can just use isset for this. E.g. isset($_GET['foo'], $_GET['bar'], $_GET['baz']). I think accepting an array for array_key_exists is not very clear, because it could mean either "one of the keys exists" or "all of the keys exist". Marking as Wfx, unless some clearer examples for use cases come up ;) Previous Comments: ------------------------------------------------------------------------ [2013-05-16 07:44:48] bensor987 at neuf dot fr Description: ------------ Why can't we give an array as the first parameter of array_key_exists() ? I have a few cases where it would be useful. Especially when checking $_POST, $_GET or $_REQUEST arrays (for instance). Test script: --------------- $array_to_test = array( 'key1' => 1, 'key2' => 1, 'key3' => 1 ); $array_keys = array( 'key1', 'key2', 'key3'); var_dump( array_key_exists( $array_keys, $array_to_test ) ); var_dump( (array_key_exists( 'key1', $array_to_test ) && array_key_exists( 'key2', $array_to_test ) && array_key_exists( 'key3', $array_to_test )) );// The same as above, but much longer. Expected result: ---------------- bool(true) bool(true) Actual result: -------------- bool(false) bool(true) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64854&edit=1