-1

我有这个数组,我想反转数据数组

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);

谢谢

4

1 回答 1

2
$arreglo['data'] = array_reverse($arreglo['data']);

array_push($datos, $arreglo)应该扭转它之前。你试过吗?

于 2015-05-23T17:45:48.043 回答