From:             
Operating system: 
PHP version:      5.4SVN-2011-11-02 (SVN)
Package:          *General Issues
Bug Type:         Bug
Bug description:Array to string notice from array functions

Description:
------------
Some of the array_* functions that compare elements in multiple arrays do
so by 
(string)$elem1 === (string)$elem2.

If $elem1 or $elem2 is an array, then the array to string notice is
thrown.

Two examples of functions that can throw this are array_intersect() and 
array_diff().

If these functions are not expected to take arrays with other arrays as
values, 
this should be mentioned on the documentation pages.

Test script:
---------------
<?php
$left = array('b', array('a'));
$right = array('a', 'd');
print_r(array_intersect($left, $right));
print_r(array_diff($left, $right));


Expected result:
----------------
Array
(
)
Array
(
    [0] => b
    [1] => Array
        (
            [0] => a
        )

)


Actual result:
--------------
PHP Notice:  Array to string conversion in /Users/simon/test.php on line 4
PHP Notice:  Array to string conversion in /Users/simon/test.php on line 4
PHP Notice:  Array to string conversion in /Users/simon/test.php on line 5
PHP Notice:  Array to string conversion in /Users/simon/test.php on line 5
PHP Notice:  Array to string conversion in /Users/simon/test.php on line 5

Notice: Array to string conversion in /Users/simon/test.php on line 4

Notice: Array to string conversion in /Users/simon/test.php on line 4

Array
(
)

Notice: Array to string conversion in /Users/simon/test.php on line 5

Notice: Array to string conversion in /Users/simon/test.php on line 5

Notice: Array to string conversion in /Users/simon/test.php on line 5

Array
(
    [0] => b
    [1] => Array
        (
            [0] => a
        )

)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=60198&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60198&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60198&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60198&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60198&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60198&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60198&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60198&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60198&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60198&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60198&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60198&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60198&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60198&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60198&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60198&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60198&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60198&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60198&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60198&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60198&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60198&r=mysqlcfg

Reply via email to