Exemplo n.º 1
0
 public static function arr_merge(array $arr1, array $arr2)
 {
     $total = func_num_args();
     $result = array();
     for ($i = 0; $i < $total; $i++) {
         foreach (func_get_arg($i) as $key => $val) {
             if (isset($result[$key])) {
                 if (is_array($val)) {
                     // Arrays are merged recursively
                     $result[$key] = Tart_Request::arr_merge($result[$key], $val);
                 } elseif (is_int($key)) {
                     // Indexed arrays are appended
                     array_push($result, $val);
                 } else {
                     // Associative arrays are replaced
                     $result[$key] = $val;
                 }
             } else {
                 // New values are added
                 $result[$key] = $val;
             }
         }
     }
     return $result;
 }