I think a foreach over the first-level keys with an array_merge() in case both are arrays would be enough

On 18.03.2009, at 14:34, mugeso wrote:

Oh, it sucks!

Then, doing by hand is the only way, I think.
As you said following function by hand is 6times slower than array_merge.

function &exactByHand(array $ar1, array $ar2)
{
    $ret = array();
    foreach($ar1 as $key=>$val) {
        if(is_int($ar1)) {
            $ret[] = $val;
            $ret[] = $ar2[$key];
        }

        if(array_key_exists($key, $ar2)) {
            if(is_array($val) && is_array($ar2[$key])) {
                $ret[$key] = exactByHand($val, $ar2[$key]);
            } else {
                $ret[$key] = $ar2[$key];
            }
        } else {
            $ret[$key] = $val;
        }
    }
    return $ret;
}
That completely ruins arrays... once you have two keys of the same name with two different scalar values, it merges those into an array instead
of overwriting the first with the second :<

So we'll do it by hand or what?

_______________________________________________
Agavi Dev Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/dev


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Agavi Dev Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/dev

Reply via email to