【发布时间】:2015-01-05 14:20:09
【问题描述】:
在过去的 9 天里,我一直在做这件事,我这辈子都想不通。
首先通过 cURL 获取 JSON 数组
$result = curl_exec($h);
curl_close($h);
var_dump(json_decode($result, true));
和的输出如下:
array(1) {
["SE"]=>
array(4) {
["errors"]=>
array(0) {
}
["billwith"]=>
string(10) "removedInteger"
["bill_detail"]=>
array(1) {
["bill_item"]=>
array(48) {
[0]=>
array(7) {
["type1identifier_id"]=>
string(5) "removed coded string "
["prod"]=>
string(15) "removed string"
["charge"]=>
string(4) "1.36"
["misc_date"]=>
string(6) "063014"
["misc_date2"]=>
string(6) "000000"
["notes"]=>
string(0) ""
["color"]=>
string(4) "hide"
}
[1]=>
array(7) {
["type1identifier_id""]=>
string(5) "CP024"
["prod"]=>
string(15) "removed string "
["charge"]=>
string(3) ".00"
["misc_date"]=>
string(6) "063014"
["misc_date2"]=>
string(6) "000000"
["notes"]=>
string(0) ""
["color"]=>
string(4) "hide"
我正在尝试将此信息写入表格以使其清晰易读,例如“删除的字符串”是我希望在标签中写入/回显的值之一,但我似乎无法取消引用任何在这个烂摊子里。
非常感谢任何帮助,谢谢!
最后一次更新,比较时每次都返回false,不太清楚为什么,我需要先声明我的值吗?这是我正在使用的代码:
if ($bill_item['charge'] == "attention")
{
echo '<tr bgcolor="red">';
echo '<td>';
echo 'charge amount DOES equal attention';
echo '</td>';
}
else
{
echo '<tr bgcolor="white">';
echo '<td>';
echo 'charge amount does NOT equal attention';
echo '</td>';
}
【问题讨论】:
-
$array["SE"]["bill_detail"]["bill_item"][0] .. [1] 等不起作用?
标签: php arrays multidimensional-array dereference