我正在尝试访问“气候”键。我可以访问“UnitFeatures”运算符之外的所有项目。
"Location": {
"Units": [
{
"BonusComments": "THIS IS A BONUS DEAL",
"CubicFootage": 125,
"OrderGrouping": "0000001CONTAINER",
"SquareFootage": 25,
"TotalUnits": 45,
"UnitFeature": {
"Access": "",
"Climate": "NON-CLIMATE",
"Doors": "",
"Elevation": "OUTSIDE",
"Floor": "1",
"Product": "CONTAINER"
},
},
]
}
我已经能够使用关联数组进行访问。我还有一个 for 循环,它将信息输出到一个表中。
$temp = "<table cellpadding='5px'>";
$temp .= "<tr><th>Unit Size</th>";
$temp .= "<th>Comments</th>";
$temp .= "<th>Unit Sq. Footage</th>";
$temp .= "<th>Units Available</th>";
$temp .= "<th>Monthly Rent</th></tr>";
for($i = 0; $i < sizeof($units) ; $i++) {
if($units[$i]["SquareFootage"]<=100) {
$temp .= "<tr>";
$temp .= "<td id='row'>" . $units[$i]["UnitSize"] . "</td>";
$temp .= "<td id='row'>" . $units[$i]["UnitFeature"]["Climate"] . "</td>";
$temp .= "<td id='row'>" . $units[$i]["SquareFootage"] . "</td>";
$temp .= "<td id='row'>" . $units[$i]["VacantUnits"] . "</td>";
$temp .= "<td id='row'>$" .$units[$i]['Monthly'] . ".00</td>";
$temp .= "</tr>";
}
}
$temp .= "</table>";
echo $temp;
我在每一种可能的配置中都尝试了包含: $units[$i]["UnitFeature"]["Climate"] 的行。
输出应为“非气候”或“气候”。
蓝山帝景
宝慕林4294392