|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-12-14 20:46 UTC] bjori@php.net
[2009-12-14 20:47 UTC] bjori@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 09:00:02 2026 UTC |
Description: ------------ in_array(0, array("a")) returns true. This is very much unexpected behavior for someone learning PHP. I see a unit test on line 38 of ext/standard/tests/array/in_array_variation4.phpt explicitly confirming this behavior. As mentioned in [14343], the current documentation does not indicate the array elements will be cast to the type of the needle. The description of the 'strict' parameter does not indicate why it may be necessary to use it. Adding the following text to the in_array function description would help: 'in_array casts the elements of the array to the type of the first parameter.' Further helpful text would be: 'If you are searching for a number in an array of strings, each string will be cast to a number. If this is not desired behavior pass "strict" as true.'