3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $fields = ['field1', 'field2']; $fields_position = [0, 3]; $row = [ 'John', 'Doe', '555 23 58 45', 'Evergreen Terrace' ]; foreach($fields_position as $idx => $pos) { $user_data[$fields[$idx]] = $row[$pos]; } var_dump($user_data);
based on 0YHA3
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.2.4
array(2) { ["field1"]=> string(4) "John" ["field2"]=> string(17) "Evergreen Terrace" }