3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array_1 = array("1a" =>"dogs","2a" => "cats","3a" => "birds","4a" => "people"); $array_2 = array("4a" => "walking","2a" => "cats"); foreach ($array_1 as $key_1 => $value_1) { if (array_key_exists($key_1, $array_2)) { $array_1[$key_1] = $array_2[$key_1]; } } print_r($array_1);
Output for 4.3.0 - 7.1.0
Array ( [1a] => dogs [2a] => cats [3a] => birds [4a] => walking )