php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21350 in_array return false if not array
Submitted: 2003-01-02 14:42 UTC Modified: 2003-01-02 16:08 UTC
From: marc at rushland dot net Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.2.1 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marc at rushland dot net
New email:
PHP Version: OS:

 

 [2003-01-02 14:42 UTC] marc at rushland dot net
When you pass a non-array as the second arguement (i.e. the haystack) to in_array(), I think it would be more useful if PHP simply returned FALSE, instead of issuing a WARNING error.

Checking an array against is_array() before calling in_array() in a conditional expression only leads to more complicated code when I think it is quite logical for PHP to simply return false.

Marc.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-02 16:08 UTC] edink@php.net
You can silence to warning by calling @in_array() if you know what you are doing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 05:01:34 2025 UTC