【发布时间】:2018-09-12 18:04:18
【问题描述】:
我想通过 in_array 函数和 For 循环在数组值中搜索。我的代码:
$input = "a";
$arrays = array("cdf","abs","tgf");
$counter = count($arrays);
for ($i=0; $i<$counter; $i++){
if(in_array($input,$arrays) !== true){
echo "Found <br>";
} else {
echo "Not Found";
}
}
输出:
Not Found
Found
Not Found
但是,if(in_array($input,$arrays[$i]) !== true) 不起作用。
【问题讨论】:
标签: arrays loops if-statement