-1

I've got this array, and i would like to reverse the data array

Array
(
    [0] => Array
        (
            [name] => Name
            [data] => Array
                (
                    [22] => 1679076
                    [21] => 1674610
                    [20] => 1669738
                    [19] => 1664289
                    [18] => 1654116
                    [17] => 1653805
                    [16] => 1652625
                )

        )

)

and i'd like to have it this way

Array
(
    [0] => Array
        (
            [name] => Name
            [data] => Array
                (
                    [16] => 1679076
                    [17] => 1674610
                    [18] => 1669738
                    [19] => 1664289
                    [20] => 1654116
                    [21] => 1653805
                    [22] => 1652625
                )

        )

)

Is it possible to revers it? I've tried with array_reverse without success

Array it's created like this

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

Thanks

Zuker
  • 456
  • 2
  • 6
  • 18

1 Answers1

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

before the array_push($datos, $arreglo) should reverse it. Have you tried that?