改变JSON格式php

I have this php code that i need to change the JSON format i get the data from a mysql db:

// Retrieve data from database 
    $sql="SELECT nombre FROM deudores ORDER BY fecha ASC LIMIT 10";
    $result=mysqli_query($con, $sql);

    $emparray = array();
    // Start looping rows in mysql database.
    while($rows=mysqli_fetch_assoc($result)){
        $emparray[] = $rows;
    // close while loop 
    }
    //print_r($emparray);
    //echo json_encode($emparray);
    $output = array(
   'c2array' => true,
   'size' => array(
       0 => count($emparray),
       1 => 1,
       2 => 1
   ),
   'data' => array()
    );

    $x = 0;
    foreach ($emparray as $value) {
   $output['data'][$x] = array();
   $output['data'][$x][0] = array();
   $output['data'][$x][0][0] = $value;
   $x++;
    }

    echo json_encode($output);

That code print this JSON:

{"c2array":true,"size":[7,1,1],"data":[[[{"nombre":"test"}]],[[{"nombre":"Oscar"}]],[[{"nombre":"Oscar"}]],[[{"nombre":"test"}]],[[{"nombre":"test"}]],[[{"nombre":"oscar"}]],[[{"nombre":"Oscar"}]]]}

but i need the JSON to look like this:

{"c2array":true,"size":[7,1,1],"data":[[[test]],[[Oscar]],[[Oscar]],[[test]],[[test]],[[oscar]],[[Oscar]]]}

How can i achive this?

Thanks in advance!

Use mysql_fetch_row() instead of mysql_fetch_assoc.

while($rows=mysqli_fetch_row($result)){
    $emparray[] = $rows;
// close while loop 
}

And just set $emparray as value for $output['data']. No need extra work!

$output['data'] = $emparray;

This should make the output like this :

{"c2array":true,"size":[7,1,1],"data":[["test"],["Oscar"],["Oscar"],["test"],["test"],["oscar"],["Oscar"]]}