我想重命名多维数组中的键。我看着这个:Renaming the keys in multidimensional associate arrays它重命名它,但只为我的2个阵列中的一个。我怎样才能得到它重命名第一阵列time
和第二阵列count
?重命名多维数组键
我的输出现在的问题是:
Array
(
[0] => Array
(
[0] => 00:00
[1] => 00:15
[2] => 00:30
)
[1] => Array
(
[0] => 8
[1] => 9
[2] => 8
)
)
我需要[0]
是time
和[1]
是count
。
如果我用这个:
foreach ($sliced_array as $id => $dataset) {
$newArray["time"] = $dataset;
}
我能得到它的输出只改名为time
阵列[1]
。它应该是count
和阵列[0]
完全消失。有没有办法将哪个数据集集中在foreach目标上? dataset[0]
不起作用。
我的预期输出是:
Array
(
[time] => Array
(
[0] => 00:00
[1] => 00:15
[2] => 00:30
)
[count] => Array
(
[0] => 8
[1] => 9
[2] => 8
)
)
你预期的输出结果看起来像? –