2012-07-26 24 views
0
$numbers = array('1','2','3','4'); 
$number = '1'; 

是否有任何方法將所有數字與數字進行比較,以查看某些數值是否等於$數字?PHP中是否有內置函數來比較變量與數組中的許多變量?

+7

'in_array(1,陣列( '1', '2', '3', '4'))',或更清楚地解釋你需要什麼。 – 2012-07-26 03:01:38

+0

下次嘗試使用Google搜索。掃描[此列表](http://php.net/manual/en/ref.array.php)可能會揭示你的答案 – 2012-07-26 03:02:46

+0

@邁克爾說了些什麼。 – nickb 2012-07-26 03:03:52

回答

0

是有:

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