Create a json that contains object inside an object in PHP and mysql

What I ultimately want to do is create an api in the format of a json object and pass it along to the front end. And the data is the result of MySQL query.I want to have the structure as this json:

I’ve tried this code

    // cityinfo array

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        [$row['Date']] = [$row[`NewCases`]];
            "CityName" => $CityName,
            [$row['Date']] = [$row[`NewCases`]], 
        array_push($city_arr["records"], $city_item);

but it returns

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.