我有三个数组,我想将它们与多维关联数组组合。
原始数组
$statiosnIds = [12, 17, 20, 32];
$distances = [0, 2.5, 3.0, 6.2];
$orders = [0, 1, 2, 3];
结果查看
$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,
]
];
我可以为每个循环使用三个来完成此操作,但我想知道是否有更好、更优化的方法来实现它。
MYYA