3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $fields = [ 'field1' => 'Name', 'field2' => 'Street' ]; $fields_position = [0, 3]; $values = [ 'John', 'Doe', '555 23 58 45', 'Evergreen Terrace' ]; foreach($fields_position as $idx => $pos) { $user_data[$fields[$idx]] = $values[$pos]; } var_dump($user_data);
Output for 5.6.0 - 5.6.30, 7.1.0 - 7.2.4
Notice: Undefined offset: 0 in /in/SNWHu on line 18 Notice: Undefined offset: 1 in /in/SNWHu on line 18 array(1) { [""]=> string(17) "Evergreen Terrace" }
Output for hhvm-3.22.0
Notice: Undefined index: 0 in /in/SNWHu on line -1 Notice: Undefined index: 1 in /in/SNWHu on line -1 array(1) { [""]=> string(17) "Evergreen Terrace" }
Output for hhvm-3.18.5 - 3.21.3
Notice: Undefined index: 0 in /in/SNWHu on line 18 Notice: Undefined index: 1 in /in/SNWHu on line 18 array(1) { [""]=> string(17) "Evergreen Terrace" }