lets having user provide information.
array 1 but not required. have defaults.
array 2 does php have function overwrite array values of array 2 based on if supplied in array 1, , not empty?
i'm not sure either of these answers helping out (they didn't me) case when "defualts" may associative array more 1 level deep.
i think looking array_replace_recursive.
$finalarray = array_replace_recursive(array $defaults, array $inputoptions)
heres example takes optional array of options function , processing based on result of options "opts" , defaults specify:
function do_something() { $args = func_get_args(); $opts = $args[0] ? $args[0] : array(); $defaults = array( "second_level" => array( "key1" => "val1", "key2" => "val2" ), "key1" => "val1", "key2" => "val2", "key3" => "val3" ); $params = array_replace_recursive($defaults, $opts); // these merged parameters } check out here
Comments
Post a Comment