Chartjs-Is possible convert an associative array in indexed array in php?

1๐Ÿ‘

โœ…

<?php
$a[0]['key1']=1;
$a[0]['key2']=2;
$a[1]['key1']=3;
$a[1]['key2']=4;

foreach ($a as $b){
    $new[] = array_values($b);
}

print_r($new);

output:

Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 2
        )

    [1] => Array
        (
            [0] => 3
            [1] => 4
        )

)

ref: https://www.php.net/manual/en/function.array-values.php

Leave a comment