【发布时间】:2017-09-15 22:13:10
【问题描述】:
有没有办法确定一个变量是否等于数组中任何变量的值? 例如,
IF ($a == $b) {
echo "there is a match";
}
//where $b is an array of values
//and $a is just a single value
【问题讨论】:
-
你试过循环数组吗?如果没有内置的,那将是直接的方法。
-
所以基本上你想检查一个数组是否包含某个值?
-
数组不包含变量,它们包含值。
-
array_intersect() 比 in_array() 快很多
标签: php