PHP 中是否有内置函数将变量与数组中的许多变量进行比较


Is there a built in function in PHP to compare a variable with many variables in an array?

$numbers = array('1','2','3','4');
$number = '1';

有没有办法将所有数字与数字进行比较,以查看某些值是否等于$number?

是的,有:

if(in_array(1, array('1','2','3','4')))
{
     echo 'It in here';
}else{ echo 'nope its not';}