我整晚都在为这个嵌套数组苦苦挣扎,所以我最终决定在这方面寻求一些帮助。我正在尝试将下面的嵌套数组更正为其他内容。请回复代码示例/解决方案。我不是最好的 PHP 程序员。谢谢大家!
我希望它看起来像什么:
array
0 =>
'enginename' => string 'Engine1' (length=19)
'status' => string 'up' (length=2)
'time' => string '2013-04-17 09:28:00' (length=19)
1 =>
'enginename' => string 'Engine2' (length=19)
'status' => string 'up' (length=2)
'time' => string '2013-04-17 09:28:00' (length=19)
它目前的样子:
Writing data...
The total # of columns in this query are: 3
The length of the first array is: 363
array
0 =>
array
0 =>
array
'enginename' => string 'Engine1' (length=19)
1 =>
array
'status' => string 'up' (length=2)
2 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
1 =>
array
3 =>
array
'enginename' => string 'Engine2' (length=20)
4 =>
array
'status' => string 'up' (length=2)
5 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
2 =>
array
6 =>
array
'enginename' => string 'Engine3' (length=30)
7 =>
array
'status' => string 'up' (length=2)
8 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
更新 4/24 上午 10:26:: bwoebi 的示例输出 这很好,谢谢,但不是 100% 我需要的。它删除了嵌套数组,但也再次分离了所有键。我需要一个“组”中的前 3 个键,就像我原来的示例所示。
array
0 =>
array
'enginename' => string 'Engine1' (length=19)
1 =>
array
'status' => string 'up' (length=2)
2 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
3 =>
array
'enginename' => string 'Engine2' (length=20)
4 =>
array
'status' => string 'up' (length=2)
5 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
6 =>
array
'enginename' => string 'Engine3' (length=30)
7 =>
array
'status' => string 'up' (length=2)
8 =>
array
'time' => string '2013-04-17 09:28:00' (length=19)
更新 4/24 上午 10:36:: bwoebi 的更正示例输出
array
0 =>
array
'enginename' => string 'Engine1' (length=19)
'status' => string 'up' (length=2)
'time' => string '2013-04-17 09:28:00' (length=19)
1 =>
array
'enginename' => string 'Engine2' (length=20)
'status' => string 'up' (length=2)
'time' => string '2013-04-17 09:28:00' (length=19)
2 =>
array
'enginename' => string 'Engine3' (length=30)
'status' => string 'up' (length=2)
'time' => string '2013-04-17 09:28:00' (length=19)