3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( "0" => Array ( "id_user" => "1", "name_user" => "Thomas" ), "1" => Array ( "id_user" => "3", "name_user" => "David" ) ); foreach($array as $array_val) { $key = $array_val['id_user']; $val = $array_val['name_user']; $new_array[$key] = $val; } print_r($new_array);
Output for 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
Array ( [1] => Thomas [3] => David )

preferences:
118.27 ms | 404 KiB | 234 Q