我有以下數組。我想動態更新這個數組。將數組轉換爲關聯數組
Array
(
[0] => Array
(
[id] =>
[cip] => 172.35.2.45
[ctime] => 1498718978
[uip] => 172.35.2.40
[utime] => 1498712478
[interface] => wan
[type] => pass
[disabled] => no
)
[1] => Array
(
[id] =>
[cip] => 172.35.2.24
[ctime] => 1498778578
[uip] => 172.35.2.41
[utime] => 1498532478
[interface] => wan
[type] => pass
[disabled] => no
)
)
我想將它轉換成。
Array
(
[0] => Array
(
[id] =>
updated => Array
(
[time] => 1498712478
[username] => [email protected]
)
created => Array
(
[time] => 1498712478
[username] => [email protected]
)
[interface] => wan
[type] => pass
[disabled] => no
)
[1] => Array
(
[id] =>
[updated] => Array
(
[time] => 1498532478
[username] => [email protected]
)
created => Array
(
[time] => 1498778578
[username] => [email protected]
)
[interface] => wan
[type] => pass
[disabled] => no
)
)
在這裏我們有在主陣列中的兩個元素,它可以是非常,我使用foreach循環和其他一些東西嘗試。但我不接近我想要的答案請幫我排序
您可以通過使用if(){} elseif(){}結構而不是我在此處拋出的一系列ifs來獲得性能上的緩衝 – Dano