Beispiel #1
0
 public function append($config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     self::$_config = array_merge_recursive2(self::$_config, $config);
 }
/**
 * array_merge_recursive2()
 *
 * Similar to array_merge_recursive but keyed-valued are always overwritten.
 * Priority goes to the 2nd array.
 *
 * @static yes
 * @public yes
 * @param $paArray1 array
 * @param $paArray2 array
 * @return array
 */
function array_merge_recursive2($p_Array1, $p_Array2) {
	if (!is_array($p_Array1) or !is_array($p_Array2)) {
		return $p_Array2;
	}
	foreach ( $p_Array2 AS $t_Key2 => $t_Value2) {
		$p_Array1[$t_Key2] = array_merge_recursive2( @$p_Array1[$t_Key2], $t_Value2);
	}
	return $p_Array1;
}
Beispiel #3
0
/**
 * Merges two arrays recursively.
 * Unlike the standard array_merge_recursive which converts values with duplicate keys to arrays
 * this one overwrites them.
 *
 * @param array $first
 * @param array $second
 *
 * @return array
 */
function array_merge_recursive2(&$first, &$second)
{
    $merged = $first;

    foreach ($second as $key => &$value) {
        if (is_array($value) && isset($merged [$key]) && is_array($merged[$key])) {
            $merged[$key] = array_merge_recursive2($merged [$key], $value);
        } else {
            $merged[$key] = $value;
        }
    }

    return $merged;
}
/**
 * array_merge_recursive2()
 *
 * Similar to array_merge_recursive but keyed-valued are always overwritten.
 * Priority goes to the 2nd array.
 *
 * @public yes
 * @param array|string|integer $p_array1 Array.
 * @param array|string|integer $p_array2 Array.
 * @return array
 */
function array_merge_recursive2($p_array1, $p_array2)
{
    if (!is_array($p_array1) || !is_array($p_array2)) {
        return $p_array2;
    }
    $t_merged_array = $p_array1;
    foreach ($p_array2 as $t_key2 => $t_value2) {
        if (array_key_exists($t_key2, $t_merged_array) && is_array($t_value2)) {
            $t_merged_array[$t_key2] = array_merge_recursive2($t_merged_array[$t_key2], $t_value2);
        } else {
            $t_merged_array[$t_key2] = $t_value2;
        }
    }
    return $t_merged_array;
}
Beispiel #5
0
	/**
	 * @author Nathan White
	 */
	function set_defaults_from_parameters($param_array, $key = '')
	{
		if (!empty($this->params['related_mode']) && $this->params['related_mode'] == true)
		{
			$this->markup_generator_info = $this->related_markup_generator_info;
		}
		foreach ($param_array as $k=>$v)
		{
			if (isset($this->$k))
			{
				if (is_array($this->$k))
				{
					$this->$k = array_merge_recursive2($this->$k, $v);
				}
				else $this->$k = $v;
			}
		}
	}
Beispiel #6
0
 /**
  * This is a replacement for referencing $_REQUEST directly, and gives us a consistent result that includes just $_GET and $_POST.
  *
  * It should be used instead of $_REQUEST, as the makeup of $_REQUEST depends upon the PHP version and settings.
  *
  * If $_POST and $_GET are set for a named item, $_POST is preferred.
  *
  * @param boolean run_conditional_stripslashes - defaults to true ... makes sure stripslashes gets run if magic_quotes is on.
  * @author Nathan White
  * @return array
  */
 function carl_get_request($run_conditional_stripslashes = true)
 {
     $merged = array_merge_recursive2((array) $_GET, (array) $_POST);
     return $run_conditional_stripslashes ? conditional_stripslashes($merged) : $merged;
 }
Beispiel #7
0
function array_merge_recursive2($paArray1, $paArray2)
{
    if (!is_array($paArray1) or !is_array($paArray2)) {
        return $paArray2;
    }
    foreach ($paArray2 as $sKey2 => $sValue2) {
        $paArray1[$sKey2] = array_merge_recursive2(@$paArray1[$sKey2], $sValue2);
    }
    return $paArray1;
}