I have three arrays that I want to combine with a multidimensional associative array.
Original Array
$statiosnIds = [12, 17, 20, 32];
$distances = [0, 2.5, 3.0, 6.2];
$orders = [0, 1, 2, 3];
Result Looking
$data = [
[
'station_id' => 12,
'distance' => 0,
'order' => 0,
],
[
'station_id' => 17,
'distance' => 2.5,
'order' => 1,
],
[
'station_id' => 20,
'distance' => 3.0,
'order' => 2,
],
[
'station_id' => 32,
'distance' => 6.2,
'order' => 3,
]
];
I can do it using three for each loop, but I want to know if there is any better and more optimized way to achieve it.