#48362 [Opn->Bgs]: documentation for in_array should honor type conversion

From: Date: Fri, 22 May 2009 16:13:04 +0000
Subject: #48362 [Opn->Bgs]: documentation for in_array should honor type conversion
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2297@lists.php.net to get a copy of this message
ID: 48362 Updated by: lbarnaud@php.net Reported By: jketterl at chipxonio dot de -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: linux PHP Version: Irrelevant New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. This is how comparison is done by default in PHP and this do not need to be documented for every function. When comparing a string to a string, if both represent a number, they are compared as numbers. This is what allows you to do things like ($_GET['foo'] > $_GET['bar']) without taking care of types. Strict comparison can be used instead. <?php ("+36901112222" == "36901112222") === true // loose comparison ("+36901112222" === "36901112222") === false // strict comparison ?> Previous Comments: ------------------------------------------------------------------------ [2009-05-22 11:38:33] jketterl at chipxonio dot de Description: ------------ the in_array() function apparently converts the given $needle and all members of $haystack to int when the third parameter is left out / false (see also http://bugs.php.net/bug.php?id=37235). since this seems to be expected behaviour (which i disagree about, but that's not the point here) it should be explicitly documented on the corresponding manual page. background: the conversion basically makes the function useless for string keys without strict comparison since they will convert to zero most of the time. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48362&edit=1

« previous php.doc.bugs (#2297) next »