【发布时间】:2021-09-09 21:22:08
【问题描述】:
我正在使用 php,我有关联数组,我想计算总数 键为“IsRatingQuestion”且值为 =“1”的数组(使用循环)数 这是我的数组
Array
(
[0] => Array
(
[ques_id] => 2
[question] => Please enter your mobile number.
[IsRatingQuestion] => 0
[ISSubQuestion] =>
)
[1] => Array
(
[ques_id] => 2
[question] => Lorem Ipsum dummy text
[IsRatingQuestion] =>
[ISSubQuestion] =>
)
[2] => Array
(
[ques_id] => 15
[question] => Would your recommend TOSSIN ?
[IsRatingQuestion] => 1
[ISSubQuestion] =>
)
[3] => Array
(
[ques_id] => 18
[question] => which type of mobile you have ?
[IsRatingQuestion] =>1
[ISSubQuestion] => 1
)
这是我的 php 代码(现在计算所有记录/数组),我想计算键为“IsRatingQuestion”且值为 =“1”的数组,我该怎么做?提前致谢。
<?php
$count=count($rec);
for ($j = "2"; $j < $count+"1"; $j++)
{
?>
<li>Step <?php echo $j; ?></li>
<?php } ?>
【问题讨论】: