Re: PHP_Compat

From: Date: Sun, 20 Jun 2004 02:13:14 +0000
Subject: Re: PHP_Compat
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30941@lists.php.net to get a copy of this message
Tobias Schlitt wrote:
I've also an addition for PHP_Compat, which does not really add a compatibility function, but solves a very nasty issue of (AFAIK) all PHP versions: array_merge(). The array_merge function does not provide the functionality one would expect and (AFAIK) how it is documented. I once copied this little function from Lukas which implements the desired functionality: <snip>
    function array_merge_private ( $arr1, $arr2 ) {
        if (!is_array($arr1) || !is_array($arr2)) {
            return false;
        }
        foreach ($arr2 as $k => $v) {
            if (is_array($v) && isset($arr1[$k]) && is_array($arr1[$k]))
            {
                $arr1[$k] = array_merge_private($arr1[$k], $v);
            } else {
                $arr1[$k] = $v;
            }
        }
        return $arr1;
    }
</snip>
"Extensions" to PHP shouldn't go into a PHP_Compat package, IMHO. That seems out of place and can be a problem for forward compatibility. Not that the function is bad, just doesn't belong here... This kind of things should stick to the "User Comments" of the PHP manual... If you really want something like this in PEAR, it would have to be made into a package... for instance PHP::array_merge_private()...? My $0.02... -Philippe

« previous php.pear.dev (#30941) next »