大佬教程收集整理的这篇文章主要介绍了如何将这些 Array Response 放在表格中或回显它?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个数组响应,我对 PHP 和 Curl 很陌生。我希望将此跟踪详细信息(例如状态时间、状态正文和位置)放入表格中。我尽力了,但无法将其放入表格中,甚至无法回显以下数据。我尝试使用 foreach,但不知道如何正确使用。请为此提供最佳解决方案:) 谢谢
(
[info] => Array
(
[courIEr_name] => delhivery
[to_pincode] => 226020
[from_pincode] => 587122
[to_city] => LUCKNow
[from_city] => HUBli
[cod_amount] => 0
)
[track_arr] => Array
(
[0] => Array
(
[status_array] => Array
(
[0] => Array
(
[status_time] => 10 Feb 2021,16:34
[status_body] => Shipment picked up
[status_location] => Mudhol_ManturRD_D (Karnataka)
)
[1] => Array
(
[status_time] => 10 Feb 2021,20:24
[status_body] => Shipment RecIEved at Origin Center
[status_location] => Mudhol_ManturRD_D (Karnataka)
)
[2] => Array
(
[status_time] => 10 Feb 2021,20:25
[status_body] => Added to Bag
[status_location] => Mudhol_ManturRD_D (Karnataka)
)
[3] => Array
(
[status_time] => 11 Feb 2021,08:58
[status_body] => Bag Added To Trip
[status_location] => Mudhol_ManturRD_D (Karnataka)
)
[4] => Array
(
[status_time] => 11 Feb 2021,12:08
[status_body] => Trip Arrived
[status_location] => Bijapur_Jamakhandi_I (Karnataka)
)
[5] => Array
(
[status_time] => 11 Feb 2021,12:14
[status_body] => Bag Received at Facility
[status_location] => Bijapur_Jamakhandi_I (Karnataka)
)
[6] => Array
(
[status_time] => 11 Feb 2021,13:07
[status_body] => Shipment Received at Facility
[status_location] => Bijapur_Jamakhandi_I (Karnataka)
)
[7] => Array
(
[status_time] => 11 Feb 2021,13:33
[status_body] => Added to Bag
[status_location] => Bijapur_Jamakhandi_I (Karnataka)
)
[8] => Array
(
[status_time] => 12 Feb 2021,01:41
[status_body] => Bag Added To Trip
[status_location] => Bijapur_Jamakhandi_I (Karnataka)
)
[9] => Array
(
[status_time] => 12 Feb 2021,11:46
[status_body] => Trip Arrived
[status_location] => Kolhapur_Central_H_2 (Maharashtra)
)
[10] => Array
(
[status_time] => 12 Feb 2021,11:52
[status_body] => Bag Received at Facility
[status_location] => Kolhapur_Central_H_2 (Maharashtra)
)
[11] => Array
(
[status_time] => 12 Feb 2021,12:11
[status_body] => Shipment Received at Facility
[status_location] => Kolhapur_Central_H_2 (Maharashtra)
)
[12] => Array
(
[status_time] => 12 Feb 2021,12:12
[status_body] => Added to Bag
[status_location] => Kolhapur_Central_H_2 (Maharashtra)
)
[13] => Array
(
[status_time] => 12 Feb 2021,15:06
[status_body] => Bag Added To Trip
[status_location] => Kolhapur_Central_H_2 (Maharashtra)
)
[14] => Array
(
[status_time] => 14 Feb 2021,08:51
[status_body] => Trip Arrived
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[15] => Array
(
[status_time] => 14 Feb 2021,11:18
[status_body] => Bag Received at Facility
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[16] => Array
(
[status_time] => 14 Feb 2021,12:38
[status_body] => Bag Added To Trip
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[17] => Array
(
[status_time] => 14 Feb 2021,14:06
[status_body] => Trip Arrived
[status_location] => Gurgaon_Bilaspur_HB (Haryana)
)
[18] => Array
(
[status_time] => 14 Feb 2021,14:14
[status_body] => Received At Delhivery Hub
[status_location] => Gurgaon_Bilaspur_P (Haryana)
)
[19] => Array
(
[status_time] => 14 Feb 2021,14:14
[status_body] => Bag Received at Facility
[status_location] => Gurgaon_Bilaspur_HB (Haryana)
)
[20] => Array
(
[status_time] => 14 Feb 2021,14:42
[status_body] => Shipment Received at Facility
[status_location] => Gurgaon_Bilaspur_P (Haryana)
)
[21] => Array
(
[status_time] => 14 Feb 2021,15:15
[status_body] => Added to Bag
[status_location] => Gurgaon_Bilaspur_P (Haryana)
)
[22] => Array
(
[status_time] => 14 Feb 2021,15:15
[status_body] => System weight captured
[status_location] => Gurgaon_Bilaspur_P (Haryana)
)
[23] => Array
(
[status_time] => 14 Feb 2021,15:15
[status_body] => Received At Delhivery Hub
[status_location] => Gurgaon_Bilaspur_HB (Haryana)
)
[24] => Array
(
[status_time] => 14 Feb 2021,15:23
[status_body] => Bag Added To Trip
[status_location] => Gurgaon_Bilaspur_HB (Haryana)
)
[25] => Array
(
[status_time] => 14 Feb 2021,16:06
[status_body] => Trip Arrived
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[26] => Array
(
[status_time] => 14 Feb 2021,17:03
[status_body] => Bag Received at Facility
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[27] => Array
(
[status_time] => 14 Feb 2021,23:34
[status_body] => Bag Added To Trip
[status_location] => Gurgaon_Tauru_GW (Haryana)
)
[28] => Array
(
[status_time] => 15 Feb 2021,14:28
[status_body] => Trip Arrived
[status_location] => LuckNow_Memaura_H (Uttar Pradesh)
)
[29] => Array
(
[status_time] => 15 Feb 2021,16:13
[status_body] => Bag Received at Facility
[status_location] => LuckNow_Memaura_H (Uttar Pradesh)
)
[30] => Array
(
[status_time] => 15 Feb 2021,20:52
[status_body] => Shipment Received at Facility
[status_location] => LuckNow_Memaura_H (Uttar Pradesh)
)
[31] => Array
(
[status_time] => 15 Feb 2021,20:55
[status_body] => Added to Bag
[status_location] => LuckNow_Memaura_H (Uttar Pradesh)
)
[32] => Array
(
[status_time] => 16 Feb 2021,03:10
[status_body] => Bag Added To Trip
[status_location] => LuckNow_Memaura_H (Uttar Pradesh)
)
[33] => Array
(
[status_time] => 16 Feb 2021,07:06
[status_body] => Trip Arrived
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
[34] => Array
(
[status_time] => 16 Feb 2021,07:12
[status_body] => Bag Received at Facility
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
[35] => Array
(
[status_time] => 16 Feb 2021,07:45
[status_body] => Shipment Received at Facility
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
)
[status_name] => OT
)
[1] => Array
(
[status_array] => Array
(
[0] => Array
(
[status_time] => 16 Feb 2021,08:42
[status_body] => Out for delivery
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
[1] => Array
(
[status_time] => 16 Feb 2021,12:36
[status_body] => Call placed to consignee
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
)
[status_name] => OO
)
[2] => Array
(
[status_array] => Array
(
[0] => Array
(
[status_time] => 16 Feb 2021,12:37
[status_body] => Delivered to consignee - OTP VerifIEd delivery
[status_location] => LuckNow_Aliganj (Uttar Pradesh)
)
)
[status_name] => DL
)
)
[edd_stamp] => 16 Feb 2021,23:59
[err] =>
[web_address] =>
[auth_token] =>
[clIEnt_order_ID] => 1720402027
[status] => Array
(
[received_by] =>
[current_status_type] => DL
[current_status_body] => Your Order has been successfully Delivered
[current_status_location] => LuckNow_Aliganj (Uttar Pradesh)
[current_status_time] => 16 Feb 2021,12:37
)
[company_name] =>
[tracking_ID] => 782372067934
[courIEr_used] => Delhivery
[logo] =>
[courIEr_tracking_ID] => 782372067934
[order_type] => forward
)
// assuming $response is array of data
$data = $response["track_arr"];
$output = [];
foreach($data as $item) {
foreach($item["status_array"] as $status) {
$output[] = [
"name" => $item["status_name"],"time" => $status["status_time"],"body" => $status["status_body"],"location" => $status["status_location"]
];
}
}
// to check array
// var_dump($output);
// https://www.php.net/manual/en/function.var-dump.php
<!DOCTYPE html>
<html>
<body>
<!-- to display collected data in table -->
<table>
<tr>
<th>Name</th>
<th>Time</th>
<th>Body</th>
<th>Location</th>
</tr>
<?php foreach($result as $item): ?>
<tr>
<td><?php echo $item['name']; ?></td>
<td><?php echo $item['time']; ?></td>
<td><?php echo $item['body']; ?></td>
<td><?php echo $item['location']; ?></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>
以上是大佬教程为你收集整理的如何将这些 Array Response 放在表格中或回显它?全部内容,希望文章能够帮你解决如何将这些 Array Response 放在表格中或回显它?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。