/**
  * Merges two arrays and replace existing entries, like the PHP function array_merge_recursive.
  * The main difference is that existing keys will be replaced with new values, not combined in a
  * new sub array.
  *
  * Usage: $newArray = array_merge_replace( $array, $newValues );
  *
  * @param array $array first array with 'replaceable' values
  * @param array $newValues array which will be merged into first one
  * @return array resulting array
  * @author Tobias Tom <*****@*****.**>
  * @todo Verify that both arguments are arrays.
  */
 public static function array_merge_replace($array, $newValues)
 {
     foreach ($newValues as $key => $value) {
         if (is_array($value)) {
             if (!isset($array[$key])) {
                 $array[$key] = array();
             }
             $array[$key] = MyOOS_Utilities::array_merge_replace($array[$key], $value);
         } else {
             if (isset($array[$key]) && is_array($array[$key])) {
                 $array[$key][0] = $value;
             } else {
                 if (isset($array) && !is_array($array)) {
                     $temp = $array;
                     $array = array();
                     $array[0] = $temp;
                 }
                 $array[$key] = $value;
             }
         }
     }
     return $array;
 }