3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $inputs = [ 'set1' => [ 'key1' => 'value1', 'key2' => 'value2' ], 'set3' => [ 'key1' => 'value1114', 'key2' => 'value2224' ], 'set2' => [ 'key1' => 'value111', 'key2' => 'value222' ], ]; $outputs = [ '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', ] ]; $inputs2 = [ 'from' => [ 'postalCode' => '1234AB', 'houseNumber' => '11', ], 'to' => [ 'postalCode' => '5678CC', 'houseNumber' => '21', ] ]; $outputs2 = [ '51cb9c71491c4bd4b8bc05dc7f3fca86' => [ 'postalCode' => '1234AB', 'houseNumber' => '11', ], 'd0179cd2ddd5436da9785c76cce4320c' => [ 'postalCode' => '5678CC', 'houseNumber' => '22', ] ]; foreach($outputs2 as $key => $value) { foreach($inputs2 as $input => $values) { if (array_intersect($value, $values) == $values) { $result[$key] = $value; unset($notIn[$input]); } else { $notIn[$input] = $values; } } } var_dump($notIn); var_dump($result);
Output for 5.6.30, 7.0.30 - 7.3.1
Notice: Undefined variable: notIn in /in/YBNKg on line 73 array(2) { ["to"]=> array(2) { ["postalCode"]=> string(6) "5678CC" ["houseNumber"]=> string(2) "21" } ["from"]=> array(2) { ["postalCode"]=> string(6) "1234AB" ["houseNumber"]=> string(2) "11" } } array(1) { ["51cb9c71491c4bd4b8bc05dc7f3fca86"]=> array(2) { ["postalCode"]=> string(6) "1234AB" ["houseNumber"]=> string(2) "11" } }
Output for hhvm-3.18.5 - 3.22.0
array(2) { ["to"]=> array(2) { ["postalCode"]=> string(6) "5678CC" ["houseNumber"]=> string(2) "21" } ["from"]=> array(2) { ["postalCode"]=> string(6) "1234AB" ["houseNumber"]=> string(2) "11" } } array(1) { ["51cb9c71491c4bd4b8bc05dc7f3fca86"]=> array(2) { ["postalCode"]=> string(6) "1234AB" ["houseNumber"]=> string(2) "11" } }