3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $name = array('name1', 'name2'); $email = array('email1', 'email2'); function array_combine_values_assoc(array $keys, array $data = []) { if (func_num_args() > 2) { $data = array_slice(func_get_args(), 1); } return array_map(function ($key) use ($keys, $data) { return array_combine($keys, array_column($data, $key)); }, array_keys(current($data))); } var_dump(array_combine_values_assoc(['name', 'email'], $name, $email)); var_dump(array_combine_values_assoc(['name', 'email'], [$name, $email]));
based on LKIBE
Output for 5.5.24 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> array(2) { ["name"]=> string(5) "name1" ["email"]=> string(6) "email1" } [1]=> array(2) { ["name"]=> string(5) "name2" ["email"]=> string(6) "email2" } } array(2) { [0]=> array(2) { ["name"]=> string(5) "name1" ["email"]=> string(6) "email1" } [1]=> array(2) { ["name"]=> string(5) "name2" ["email"]=> string(6) "email2" } }
Output for 5.4.0 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/opT8E on line 13
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/opT8E on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/opT8E on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/opT8E on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/opT8E on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/opT8E on line 6
Process exited with code 255.