3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = [ 'set1' => [ 'key1' => 'value1', 'key2' => 'value2' ], 'set2' => [ 'key1' => 'value111', 'key2' => 'value222' ] ]; $output = [ 'out2' => [ 'key1' => 'value11', 'key2' => 'value22', 'key3' => 'value33', 'key4' => 'value44', 'key5' => 'value55', 'key6' => 'value66', ], 'out3' => [ 'key1' => 'value111', 'key2' => 'value222', 'key3' => 'value333', 'key4' => 'value444', 'key5' => 'value555', 'key6' => 'value666', ] ]; foreach($output as $key => $value) { foreach($input as $inputs) { if (array_intersect($value, $inputs) == $inputs) { $result[$key] = $value; } else { $missingSets[key($input)] = $inputs; } } } var_dump($result); var_dump($missingSets);
Output for hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.2.6
array(1) { ["out3"]=> array(6) { ["key1"]=> string(8) "value111" ["key2"]=> string(8) "value222" ["key3"]=> string(8) "value333" ["key4"]=> string(8) "value444" ["key5"]=> string(8) "value555" ["key6"]=> string(8) "value666" } } array(1) { ["set1"]=> array(2) { ["key1"]=> string(6) "value1" ["key2"]=> string(6) "value2" } }
Output for 5.6.30
array(1) { ["out3"]=> array(6) { ["key1"]=> string(8) "value111" ["key2"]=> string(8) "value222" ["key3"]=> string(8) "value333" ["key4"]=> string(8) "value444" ["key5"]=> string(8) "value555" ["key6"]=> string(8) "value666" } } array(1) { ["set2"]=> array(2) { ["key1"]=> string(6) "value1" ["key2"]=> string(6) "value2" } }