[Solved] how to add new array in JSON using PHP with this format? [closed]


Data field is array of objects? If yes, try something like this…

$array = [
    "table-name"=>"Beta",
    "created-on"=>"May 03, 2021",
    "token"=>"6kh3o0oRLZreJ9K",
    "columns"=>"Name,Org,Address,Mobile,Email,Pass",
    "data" => []
]

$data = [
    "Name" => $_POST["fullname"],
    "Org" => $_POST["organization"],
    "Address" => $_POST["address"],
    "Mobile" => $_POST["phone"],
    "Email" => $_POST["email"],
    "Pass" => $_POST["password"]
];

array_push($array["data"], $data);
$json = json_encode($array);

2

solved how to add new array in JSON using PHP with this format? [closed]