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

Reply via email to