我有以下格式的数据:
{
"jobname" : "2018_09_27_test123_0",
"totalcalls" : 1836.0,
"success" : 3.0,
"fail" : 1833.0,
"failureReasons" : [
{
"reason" : "Unavailable",
"count" : 53.0
},
{
"reason" : "SIP_RedirectFailed",
"count" : 1698.0
},
{
"reason" : "Ringingtimeout",
"count" : 64.0
},
{
"reason" : "Misc",
"count" : 10.0
},
{
"reason" : "UnallocatedNumber",
"count" : 7.0
},
{
"reason" : "SIP_AckNotReceived",
"count" : 1.0
}
]
}
我想以表格格式显示此数据。我能够显示职位名称,总电话,成功和失败,但无法显示失败原因。我想在表中显示失败原因计数。
foreach ($cursor as $venue) {
echo "<tr>";
echo "<td>" . $venue['jobname'] . "</td>";
echo "<td>" . $venue['totalcalls'] . "</td>";
echo "<td>" . $venue['success'] . "</td>";
echo "<td>" . $venue['fail'] . "</td>";
}
但是我发现阅读失败原因的问题。我想计算原因并放在表格中:
<td>Ringingtimeout</td>
<td>UnallocatedNumber</td>
<td>SIP_AckNotReceived</td>`
答案 0 :(得分:0)
要计算失败原因,可以使用count($venue['failureReasons'])
。
还要显示以下所有原因
foreach ($c as $venue['fail']) {
echo $c['reason']
}
此外,您想在必须使用的同一张表上显示所有原因