3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $map = ['cart' => ['items' => ['product' => []]]]; $result = [ 'cart' => ['a' => 10, 'b' => 20], 'items' => ['c' => 3], 'product' => ['e' => 66], ]; $mapRes = $map; function get(&$map, $result, &$mapRes) { $val = &$map; foreach ($val as $key => &$m) { var_dump( array_walk_recursive($m, 'test_print')); if (!empty($m)) { get($m, $result,$mapRes); } //var_dump($m); // $val[$key] = $result[$key]; //var_dump($m); } } // get($map, $result, $mapRes); // var_dump($map); function test_print(&$item, $key) { echo "La clé $key contient l'élément $item\n"; }
based on t5aBB
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc2