所以我是 php 的新手,我想问一下这是什么类型的数据?它是一个搅拌还是一个字符串数组?如果我只想在字符串中使用 name 变量,我该如何让他们说。我怎么能打电话给他们?如果它在 jsonresponse 中,我该怎么做?如果可能,我想在显示时使用 mustache 模板。基本上我想单独显示字符串中的每个数据。这是我收到的数据string(1247) "[{"name": "POSLAJU NEXT DAY","service_code": "POSMY-PN-SDP","company_code": "POSMY","description": "Booking before 11.30am. \\nPickup and delivery in 1-2 days by PosLaju. \\nAvailable on working days days only. \\nNo booking in advance later than tomorrow. \\nYou can also book online and drop your document/parcel at the nearest POSLAJU branch. \\nOnly available on the web. \\nYou have to print the Consignment Note and follow our Packaging Guidelines.","instruction": "Please print the Consignment Note and follow our Packaging Guidelines.","payment_methods": [],"cod_rate": 0,"price": 6 }, { "name": "SAME DAY - MORNING", "service_code": "MDMY-SDD-S-MORNING-KV", "company_code": "MDMY", "description": "Booking before 8am. \\nPickup before 10am. \\nDelivery before 2pm. \\nBy motorbike. \\nAvailable on working days only. \\nPayment by credit/cash by sender/cash by receiver.", "instruction": "Please label your package with our Consignment Note or Tracking No and follow our Packaging Guidelines.", "payment_methods": [ { "code": "CASHPICKUP", "name": "Cash By Sender", "price": "3" } ], "cod_rate": 0.03, "price": 15 } ]"这是jsonresponse中的代码 {"response":"[\n {\n \"name\": \"POSLAJU NEXT DAY\",\n \"service_code\": \"POSMY-PN-SDP\",\n \"company_code\": \"POSMY\",\n \"description\": \"Booking before 11.30am. \\\\nPickup and delivery in 1-2 days by PosLaju. \\\\nAvailable on working days days only. \\\\nNo booking in advance later than tomorrow. \\\\nYou can also book online and drop your document\/parcel at the nearest POSLAJU branch. \\\\nOnly available on the web. \\\\nYou have to
2 回答

慕田峪7331174
TA贡献1828条经验 获得超13个赞
它称为 JSON(代表 JavaScript Object Notation),它是一种用于在 PHP 和 JavaScript(或任何其他支持语言)之间共享数据的格式。
要在 PHP 中使用 JSON 数据,您必须将获得的字符串传递给json_decode
. 这将返回解码后的数据,在您的情况下将是一个数组。然后,您可以像使用普通数组一样访问数据。只需对解码后的字符串执行 var_dump,您就会看到它包含的数据。
- 2 回答
- 0 关注
- 116 浏览
添加回答
举报
0/150
提交
取消