3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function _object_to_array_batch($object) { return $object; } function set_insert_batch($key) { $key = _object_to_array_batch($key); var_dump(current($key)); } function insert_batch($object) { set_insert_batch($object); } function test_walk() { $foo = [ ['a' => 'hao', 'language' =>'US'], ['a' => 'buhao', 'language' =>'CN'], ]; array_walk($foo, function(&$item, $key, $parent_id) {$item['parent_id'] = $parent_id;}, 123); var_dump(current($foo)); insert_batch($foo); } test_walk();
based on Q0ILe
Output for 7.1.0 - 7.3.1
array(3) { ["a"]=> string(3) "hao" ["language"]=> string(2) "US" ["parent_id"]=> int(123) } array(3) { ["a"]=> string(3) "hao" ["language"]=> string(2) "US" ["parent_id"]=> int(123) }
Output for hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.0.20
bool(false) bool(false)
Output for 5.6.0 - 5.6.30
bool(false) array(3) { ["a"]=> string(3) "hao" ["language"]=> string(2) "US" ["parent_id"]=> int(123) }