我需要将一些数组转换为关联数组。我需要将值保存在一起。
'days1' =>
array (size=5)
0 => string '30' (length=2)
1 => string '90' (length=2)
2 => string '50' (length=2)
3 => string '50' (length=2)
4 => string '5' (length=1)
'price1' =>
array (size=5)
0 => string '5' (length=1)
1 => string '10' (length=2)
2 => string '12' (length=2)
3 => string '13' (length=2)
4 => string '1' (length=1)
'days2' =>
array (size=3)
0 => string '30' (length=2)
1 => string '90' (length=2)
2 => string '180' (length=3)
'price2' =>
array (size=3)
0 => string '6' (length=1)
1 => string '7' (length=1)
2 => string '10' (length=2)
所以days1需要与price1合并并创建类似这样的东西
array(
30 => 5,
90 =>10,
50 => 12,
50 => 13,
5 => 1
)
答案 0 :(得分:6)
使用array_combine
-
array_combine ( array $keys , array $values ) -
更多信息:http://php.net/manual/en/function.array-combine.php
顺便说一下,这不是多维数组,只是关联的。