3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $items = [ 'ITEM-1' => [ 'foo' => false, 'bar' => 'test 1'], 'ITEM-2' => [ 'foo' => true, 'bar' => 'test 2'], 'ITEM-3' => [ 'foo' => false, 'bar' => 'test 3'], ]; $items = array_filter($items, function(&$item) { if($item['foo']) { return false; } $item['bar'] = 'BAM!'; return true; }); var_dump($items);
Output for 7.0.0 - 7.2.0
array(2) { ["ITEM-1"]=> array(2) { ["foo"]=> bool(false) ["bar"]=> string(6) "test 1" } ["ITEM-3"]=> array(2) { ["foo"]=> bool(false) ["bar"]=> string(6) "test 3" } }
Output for 5.4.10 - 5.6.28
array(2) { ["ITEM-1"]=> array(2) { ["foo"]=> bool(false) ["bar"]=> string(4) "BAM!" } ["ITEM-3"]=> array(2) { ["foo"]=> bool(false) ["bar"]=> string(4) "BAM!" } }
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/6CqPc on line 2
Process exited with code 255.