note 93293 added to function.in-array
| From: | urkle at outoforder dot cc | Date: | Tue, 01 Sep 2009 20:34:28 +0000 |
| Subject: | note 93293 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160135@lists.php.net to get a copy of this message | ||
Just an FYI for anyone encountering strange issues with in_array.
$a = array('edit','view','somethingelse',0);
echo in_array('edit',$a) ? 'true' : 'false';
echo in_array('delete',$a) ? 'true' : 'false';
This returns "true" for both checks. instead of false for the second check.
I encountered this while debugging an issue in mediawiki.. one of the addons I used defined the
rights array incorrectly and added a "0" to the array so ALL RIGHTS CHECKS WERE TRUE!!!!.
http://bugs.php.net/bug.php?id=8015
this bug report basically brushes off the obvious wrong behaviour as "you must use strict
checking"
----
Server IP: 64.71.164.2
Probable Submitter: 74.202.106.37
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/93293
Del: integrated -- https://master.php.net/note/delete/93293/integrated
Del: useless -- https://master.php.net/note/delete/93293/useless
Del: bad code -- https://master.php.net/note/delete/93293/bad+code
Del: spam -- https://master.php.net/note/delete/93293/spam
Del: non-english -- https://master.php.net/note/delete/93293/non-english
Del: in docs -- https://master.php.net/note/delete/93293/in+docs
Del: other reasons-- https://master.php.net/note/delete/93293
Reject -- https://master.php.net/note/reject/93293
Search -- https://master.php.net/manage/user-notes.php