3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $source_packages = array( 'one' => array ('param1' => 'val11', 'param2' => 'val21'), 'two' => array ('param1' => 'val21', 'param2' => 'val22') ); $packages_from = $source_packages; var_dump($packages_from); echo "\n\n"; $package_key = 'two'; $package_value = $source_packages[$package_key]; $packages_to = array($package_key => $package_value); var_dump($packages_to); echo "\n"; $result_packages = array_diff_assoc($packages_from, $packages_to); var_dump($result_packages); echo "\n";
Output for 5.4.0 - 7.1.0
array(2) { ["one"]=> array(2) { ["param1"]=> string(5) "val11" ["param2"]=> string(5) "val21" } ["two"]=> array(2) { ["param1"]=> string(5) "val21" ["param2"]=> string(5) "val22" } } array(1) { ["two"]=> array(2) { ["param1"]=> string(5) "val21" ["param2"]=> string(5) "val22" } } Notice: Array to string conversion in /in/A6G6m on line 14 Notice: Array to string conversion in /in/A6G6m on line 14 array(1) { ["one"]=> array(2) { ["param1"]=> string(5) "val11" ["param2"]=> string(5) "val21" } }
Output for 4.3.0 - 5.3.29
array(2) { ["one"]=> array(2) { ["param1"]=> string(5) "val11" ["param2"]=> string(5) "val21" } ["two"]=> array(2) { ["param1"]=> string(5) "val21" ["param2"]=> string(5) "val22" } } array(1) { ["two"]=> array(2) { ["param1"]=> string(5) "val21" ["param2"]=> string(5) "val22" } } array(1) { ["one"]=> array(2) { ["param1"]=> string(5) "val11" ["param2"]=> string(5) "val21" } }