note 31415 deleted from function.array-search by felipe

From: Date: Sun, 10 Feb 2008 13:11:28 +0000
Subject: note 31415 deleted from function.array-search by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-135965@lists.php.net to get a copy of this message
Note Submitter: nospam at nowhere dot net ---- array_search won't accept objects as needle (see http://bugs.php.net/bug.php?id=20681) - a possible workaround is sth. like that: <?php function _array_search ($needle, $haystick) { foreach($haystick as $key => $val) { if ($needle === $val) { return($key); } } return(false); ?> } If you require 'bool strict' add e.g. ($strict) ? $needle === $val : $needle == $val

« previous php.notes (#135965) next »