The json array response of the PHP Web service?

hi, friends in this service I get output, but I think different outputs let me explain

$customer_id = $_POST["customer_id"];
    $response = array();
    $qry="SELECT category FROM nesbaty_customer where c_id="".$customer_id."" ";
    $qry_res=mysqli_query($con,$qry);
    $jsonData = array();
    while ($array = mysqli_fetch_assoc($qry_res)) 
    {
        $r= $array["category"];

        $jsonData[]=explode(",",$r);

    }
    echo json_encode(array("data" =>$jsonData));
    mysqli_close($con);

I get this output

{
"data": [
    [
        "Hotel",
        "Saloon"
    ]
]

but I want this output!

{
"data": [
    [
       "category": "Hotel",
       "category": "Saloon"
    ]
]
Mar.10,2021

but it certainly won't work if the format you want is not JSON, json_encode .

if you really want this format (not JSON), you have to concatenate the strings yourself.

add that the closer JSON is:

{
    "data": [
        {"category": "Hotel"},
        {"category": "Saloon"}
    ]
}
$jsonData = array_map(function($c) { return ["category" => $c];}, explode(",", $r));
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e417a4-4c042.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e417a4-4c042.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?