php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14287 array_diff takes string as second argument
Submitted: 2001-11-29 12:39 UTC Modified: 2001-11-29 13:48 UTC
From: stefan dot priebsch at e-novative dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: W2K
Private report: No CVE-ID: None
 [2001-11-29 12:39 UTC] stefan dot priebsch at e-novative dot de
Seems like array_diff will take a string as second argument, e.g.

array_diff ($bla, "fred")

where $bla is an array. No error or warning will appear, and array_diff will not work as expected (which would be removing "fred" from $bla).

Of course everything works fine using 

array_diff ($bla, array ("fred"))

However, for the above case imho there should either be a compiler warning or a note added to the manual.

Steve

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-29 13:11 UTC] derick@php.net
Both PHP 4.1.0 and php 4.2.0 dev already show this warning:

<b>Warning</b>:  Argument #2 to array_diff() is not an array in <b>-</b> on line <b>2</b><br>

so closing,

Derick
 [2001-11-29 13:48 UTC] torben@php.net
Changing this to 'bogus':

> However, for the above case imho there should either be a 
> compiler warning or a note added to the manual.

Turn up your error reporting level with error_reporting(E_ALL)
to see this kind of error. With 4.0.3pl1, I get 'Warning:  Argument #2 to array_diff() is not an array in ...' when I try this.

ALso works in recent versions.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 11:01:31 2024 UTC