我有这个数组,我想反转数据数组
Array
(
[0] => Array
(
[name] => Name
[data] => Array
(
[22] => 1679076
[21] => 1674610
[20] => 1669738
[19] => 1664289
[18] => 1654116
[17] => 1653805
[16] => 1652625
)
)
)
我希望这样做
Array
(
[0] => Array
(
[name] => Name
[data] => Array
(
[16] => 1679076
[17] => 1674610
[18] => 1669738
[19] => 1664289
[20] => 1654116
[21] => 1653805
[22] => 1652625
)
)
)
有可能扭转它吗?我尝试过使用array_reverse但没有成功
像这样创建的数组
$nombre = 'Random';
$arreglo = array();
$arreglo['name'] = $nombre;
for ($n=1; $n<=$max; $n++) {
$query = mysqli_query($connect, "QUERY");
if(mysqli_num_rows($query) != 0) {
while ($row_redes = mysqli_fetch_array($query, MYSQL_ASSOC)) {
$arreglo['data'][] = $value;
}
}else {
$arreglo['data'][] = 0;
}
}
array_push($datos, $arreglo);
由于
答案 0 :(得分:2)
$arreglo['data'] = array_reverse($arreglo['data']);
在array_push($datos, $arreglo)
应该反转它之前。你试过了吗?