我将以下数组存储在JSON文件中:
"plates": [
{
"depth": 0.8,
"width": 47.425,
"height": 50.7,
"color": "#00ff00",
"points": [],
"position": {
"x": 452.2,
"y": 236.5,
"z": 0
}
},
{
"depth": 0.8,
"width": 47.425,
"height": 50.7,
"color": "#00ff00",
"points": [],
"position": {
"x": 501.625,
"y": 183.8,
"z": 0
},
{
"depth": 0.8,
"width": 33.2666666667,
"height": 50.7,
"color": "#00ff00",
"points": [],
"position": {
"x": 70.5333333333,
"y": 236.5,
"z": 0
}
}
这是数组的缩写版本,因为它包含大约120个不同的条目,而我的问题应该可以用这个小节选来解决。
我要做的是计算包含相同宽度,高度和深度值的板的出现。我已经开始在PHP中执行以下操作:
<?php
$json = file_get_contents("wallstiles.json");
$json = json_decode($json);
$plates = $json->walls[0]->plates;
$total = 0;
foreach ($plates as $value) {
if ('???' == '???') {
}
print_r($value);
}
由于我是编程新手,因此可以使用一些指针来了解PHP的哪些功能可以为我提供帮助。 如果我以错误的方式发布了问题,请纠正我。
编辑:我将PHP文件更改为专门针对特定宽度。我现在的问题是,如何使用变量比较高度,宽度和深度这三个值,因为这似乎是最合乎逻辑的方法。但是,此时正确的语法使我无所适从。