fork(26) download
  1. <?php
  2.  
  3. $base = array('a' => 'apple', 'b' => 'banana');
  4. $replace = array('a' => 'orange', 'b' => 'grape', 'c' => 'cauliflower');
  5.  
  6. $result = array_merge($base, array_intersect_key($replace, $base));
  7.  
  8. print_r($result);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [a] => orange
    [b] => grape
)