我有一个如下数组:
$fruits = array("apple","orange","papaya","grape")
我有一个如下变量:
$content = "apple";
我需要过滤一些条件,如:如果此变量与至少一个数组元素匹配,则执行某些操作.变量$content是一堆随机字符,实际上是数组数据中可用的一个,如下所示:
$content = "eaplp"; // it's a dynamically random char from the actual word "apple`
我做了什么就像下面这样:
$countcontent = count($content);
for($a=0;$a==count($fruits);$a++){
$countarr = count($fruits[$a]);
if($content == $fruits[$a] && $countcontent == $countarr){
echo "we got".$fruits[$a];
}
}
我试着计算这些短语有多少个字母,如果……其他……当字符串中的总字符与一个数组数据中的总字符匹配时,但是除此之外我还能做些什么吗?