【发布时间】:2017-03-24 17:16:25
【问题描述】:
希望您能很好地解决我遇到的问题,即比较行(列)数组中的两个值。
有没有办法检查这些列是否匹配,因为我只检查两行,或者是每个循环的唯一方法。
我能够获取所有数据并将其放入数组中,但我使用的 if 语句在比较中不起作用。
if ($countReport == 2) {
while ($rowReport = mysqli_fetch_assoc($resultReport)) {
$temp_array[] = $rowReport;
}
//if (in_array("Hello, world",array_count_values($temp_array))){
//echo "working";
//}
}
这是数组中的数据,统计数据列是我要比较的,就像两个值都等于“hello world”。
[{"abcID":"8","stats":"Hello, world","time":"23:30:00"},
{"abcID":"7","stats":"Hi, world","time":"23:16:00"},]
【问题讨论】:
-
用你的黑魔法攻击消除那个狂野的右括号。
-
$countReport = 2应该是$countReport == 2 -
攻击失败,我现在才注释掉。使用该 if 语句只给出整数和字符串值的错误。可能会尝试使用每个代替。