<div *ngFor = "let people of peoples">
<input type = "checkbox" [value] = 'people?.name' [checked] = "people?.status">
{{people?.name}}
</div>
/****** Hide/show div (if last checkbox is checked so show is div and unchecked so hide this div ******/
<div>
<span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </span>
</div>
这是我当前的数组。我想通过phone_num仅过滤回答状态 Outpout Will喜欢这个:
Array (
[01755677011] => Array (
[0] => Array (
[0] => 1
[id] => 1
[1] => 01755677011
[phone_num] => 01755677011
[2] => NoAnswer
[status] => Answer
)
[1] => Array (
[0] => 2
[id] => 2
[1] => 01755677011
[phone_num] => 01755677011
[2] => NoAnswer
[status] => NoAnswer
)
[2] => Array (
[0] => 3
[id] => 3
[1] => 01755677011
[phone_num] => 01755677011
[2] => Answer
[status] => NoAnswer
)
[3] => Array (
[0] => 4
[id] => 4
[1] => 01755677011
[phone_num] => 01755677011
[2] => Answer
[status] => Answer
)
)
[01755677012] => Array (
[0] => Array (
[0] => 16
[id] => 16
[1] => 01755677012
[phone_num] => 01755677012
[2] =>No Answer
[status] => NoAnswer
)
[1] => Array (
[0] => 18
[id] => 18
[1] => 01755677012
[phone_num] => 01755677012
[2] => Answer
[status] => Answer
)
)
)
任何人都可以问我吗?
答案 0 :(得分:0)
我不明白你如何得到0,23代表01755677011.如果你显示的是phone_num及其拥有的次数&#34;答案&#34;状态,你可以这样做:
$result = array();
foreach ($num as $key => $row) {
$result[$key] = array();
$count = 0;
foreach($row as $key_value => $row_value) {
if ($row_value['status'] == 'Answer') {
// $key is the key 01755677011 and 01755677012
$result[$key]['id'][$count] = $row_value['id'];
$count++;
}
}
}
if (!empty($result)) {
echo "Phone Num | No of answer<br />";
foreach ($result as $key => $row) {
echo $key . " " . count($row['id']) . "<br />";
}
}
第二版:
1)基于&#34;答案&#34;在[status]或[2]中。
2)显示相应phone_num的数组索引。
$result = array();
foreach ($num as $key => $row) {
$result[$key] = array();
$count = 0;
foreach($row as $key_value => $row_value) {
if ($row_value['2'] == 'Answer' || $row_value['status'] == 'Answer') {
// $key is the key 01755677011 and 01755677012
$result[$key][$count]['index'] = $key_value;
$count++;
}
}
}
print_r($result);
if (!empty($result)) {
echo "Phone Num | No of answer<br />";
foreach ($result as $key => $row) {
echo $key . " | ";
if (!empty($row)) {
foreach ($row as $data_key => $data) {
echo $data['index'];
}
} else {
echo "No record";
}
echo "<br />";
}
}