我有以下相當簡單的代碼,其中我需要確定是否在一個陣列中存在一定值:問題與in_array
$testvalue = $_GET['testvalue']; // 4
$list = '3, 4, 5';
$array = array($list);
if (in_array($testvalue, $array)) { // Code if found } else { // Code if not found }
儘管很明顯,數字4是陣列中,所述代碼返回else支架內的代碼。我做錯了什麼?
可能把字符串作爲3,4,5 1個字符串數組中 – 2012-08-13 20:07:12