ID:               30737
 User updated by:  cfoster at frozenheads dot com
 Reported By:      cfoster at frozenheads dot com
 Status:           Bogus
 Bug Type:         Feature/Change Request
 Operating System: OS X 10.3.6
 PHP Version:      5.0.2
 New Comment:

Whoops. I had checked the manual, but missed the migration guide.

Still, it seems like the goal of a high level language should be to try
to coerce data instead of creating warnings/errors where possible.  But
I'm sure you guys had your reasons.

Sorry for the bogus bug.
-Colin.


Previous Comments:
------------------------------------------------------------------------

[2004-11-09 23:50:40] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See also the PHP 5 migration guide:
http://de.php.net/manual/en/migration5.incompatible.php

------------------------------------------------------------------------

[2004-11-09 21:01:53] cfoster at frozenheads dot com

Description:
------------
In PHP4 one could call array_merge with non-array or unset variables
and it would still correctly merge any arrays that were passed (i.e.,
type-checking was done within the function). I tested this in 4.3.8 for
BSD.

In PHP5 if any of the parameters are not arrays, the function returns
null.  I tested with 5.0.2 Mac OS X entropy release 1. 
   http://www.entropy.ch/software/macosx/php/

It was very handy to be able to pass a bunch of variables and get back
the merged result of all the arrays without having to check each one to
make sure it was set.

As is, instead of one line:

   $ar_merged = array_merge( $ar1, $ar2, $ar3, $ar4 );

one would have to have a long if-block:

$ar_merged = array();
if( is_array( $ar1 ) )
    $ar_merged = array_merge( $ar_merged, $ar1 );
if( is_array( $ar_2 ) )
    ...


Reproduce code:
---------------
<?php
$ar1 = array( "one", "two" );
$ar2 = "three";   // Optionally: comment out this line.

$ar_merged = array_merge( $ar1, $ar2 );
        
if( isset( $ar_merged ) )
    print_r( $ar_merged );
else
    print "Blarmy! Unset array!";
?>

Expected result:
----------------
In 4.3.8 it returned:

Array
(
    [0] => one
    [1] => two
    [2] => three
)

but I think it should still at least use the variables that are
arrays:

Array
(
    [0] => one
    [1] => two
)

Also, if $ar2 is not defined at all it should return:

Array
(
    [0] => one
    [1] => two
)


Actual result:
--------------
Blarmy! Unset array!

It's ignoring ALL passed variables if ANY of them are not arrays, and
returning a null result.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30737&edit=1

Reply via email to