- json_encode: documentation ( source)
<?php
$SQLRow=0;
class Trip {
}
$t = new Trip();
$t->Properties->partnerId = "1";
$t->Properties->loadTrackExternalId = $loadNumber;
$t->Properties->accountId = "12345678";
$t->Properties->dispatcherId = "";
$t->Properties->dispatcherEmail = $dispatcherEmail;
$t->Properties->dispatcherPhoneNumber = "8008888888";
$t->Properties->driverCell = $driverCell;
$t->Properties->driverName = $driverName;
$t->Properties->carrierDispatcherEmail = $carrierDispatcherEmail;
$t->Properties->Carrier->companyName = $Carrier_companyName;
$t->Properties->Carrier->contactName = $Carrier_contactName;
$t->Properties->Carrier->contactPhone = $Carrier_contactPhone;
$t->Properties->Carrier->contactPhoneExt = "";
$t->Properties->Carrier->contactEmail = $Carrier_contactEmail;
$t->Properties->Broker->companyName = "CompanyName here";
$t->Properties->Broker->contactName = "John Smith";
$t->Properties->Broker->contactPhone = "8008888888";
$t->Properties->Broker->contactPhoneExt = "";
$t->Properties->Broker->contactEmail = "jsmith@whatever.com";
$t->Properties->Shipper->loadNumber = $shipper_loadNumber;
$t->Properties->Shipper->name = $shipper_name;
$t->Properties->Shipper->shipperId = $shipper_shipperId;
$t->Properties->Shipper->emails = $shipper_email;
while($sql_row=oci_fetch_array($stid)) {
$SQLRow++;
$Stops_orderNumber[$SQLRow]=$sql_row['REFERENCE1'];
$Stops_address[$SQLRow]=$sql_row['ADDRESS1'];
$Stops_city[$SQLRow]=$sql_row['CITY'];
$Stops_state[$SQLRow]=$sql_row['STATE'];
$Stops_zipcode[$SQLRow]=$sql_row['ZIP'];
$Stops_date[$SQLRow]=$sql_row['JAPT_L_DATE'];
$Stops_time[$SQLRow]=$sql_row['LTIME'];
$Stops_appt_hours[$SQLRow]=$sql_row['APPT_HOURS'];
$Stops_email[$SQLRow]=$sql_row['EMAIL'];
$Stops = new class(){};
$Stops->orderNumber = $Stops_orderNumber[$SQLRow];
$Stops->address = $Stops_address[$SQLRow];
$Stops->city = $Stops_city[$SQLRow];
$Stops->state = $Stops_state[$SQLRow];
$Stops->zipcode = $Stops_zipcode[$SQLRow];
$Stops->datetime = "";
$t->Stops []= $Stops;
}
echo json_encode($t);