arrays - PHP function like array_replace() but does not add unknown keys -
i have associative array holds settings of object. have function allows user override these setting passing associative array of replacement settings. can use array_replace() don't want values unknown associative array keys added settings. e.g. $settings = array( 'colour' => 'red', 'size' => 'big' ); $settings = array_replace( $settings, array( 'size' => 'small', 'weight' => 'heavy' ) ); i want settings produce: array ( [colour] => red [size] => small ) instead this: array ( [colour] => red [size] => small [weight] => heavy ) first need filter out unwanted items array_intersect_key . $settings = array( 'colour' => 'red', 'size' => 'big' ); $new_settings = array( 'size' => 'small', 'weight' => 'heavy' ); $settings = array_merge($set...