note 61492 added to function.array-key-exists

From: Date: Sun, 05 Feb 2006 15:34:26 +0000
Subject: note 61492 added to function.array-key-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-103037@lists.php.net to get a copy of this message
This function is partway between strict and not strict on type matching. $x= array('that'); $test= array_key_exists(0, $x); var_dump($test); // true $x= array('that'); $test= array_key_exists('0', $x); var_dump($test); // true... not strict! $x= array('this'=>'that'); $test= array_key_exists(0, $x); var_dump($test); // false... strict! Here is a function for strict checking. It's not efficient for multiple lookups. function array_key_exists_strict($key, $array) { $keys= array_keys($array); return in_array($key, $keys, true); // strict } ---- Server IP: 64.246.30.37 Probable Submitter: 65.147.139.50 ---- Manual Page -- http://www.php.net/manual/en/function.array-key-exists.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61492 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61492&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61492&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103037) next »