-2
In this my code below it returns me json with the key "services:" however I am not able to put a name "Flight:" in the second key. how can I make this key named
$final['servicos'] = [];
$fli['flight'] = [];
foreach($list as $t) {
$data = new stdClass;
$data->id = $t->id;
$data->cliente = $t->comp_name;
$data->pax = $t->firstName;
$data->phone = $t->phone;
$data->origin = $t->origemida;
$data->destiny = $t->destinoida;
$data->status = $t->tra_status;
$data->info = $t->comments;
//voo Flight:
$fli = new stdClass;
$fli->flightNumber = $t->voo;
$fli->flightCompany = $t->cia;
$fli->flightEnd = $t->cia;
$fli->flightGate = $t->voo;
array_push($final['servicos'], $data,$fli);
}
echo json_encode($final);
Bass follows my json saida
{
"servicos": [
{
"id": 507,
"cliente": "C2RIO OFFICE NITEROI",
"pax": "Robert",
"phone": "",
"origin": "Airport GIG -RJ",
"destiny": "Hotel Hilon Barra",
"status": "3",
"info": ""
},
{
"flightNumber": "GOL4568",
"flightCompany": "GOL",
"flightEnd": "GOL",
"flightGate": "GOL4568"
} ] }
My problem is here I’d have to show up like this Flight: {
???????{
"flightNumber": "GOL4568",
"flightCompany": "GOL",
"flightEnd": "GOL",
"flightGate": "GOL4568"
} ] }
ok was exactly that.... more is affecting something in the loop. is just making a loop
– Fabio Henrique
@Fabiohenrique missed putting a
[]
when doing the push array.– Augusto Vasques
Perfect worked perfectly thank you
– Fabio Henrique