3v4l.org

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