需要檢查數組中是否存在該值,該數組是否從數據庫表中創建,它只是不與我一起工作不斷收到錯誤說「in_array()期望參數2是數組,字符串給出「 有人可以請幫忙嗎?檢查數據庫數組中存在的值是否不起作用
PHP代碼
<?php
$lang='en';
$query_rsLanguages = "SELECT * FROM languages";
$rsLanguages = mysql_query($query_rsLanguages);
$languages_array = array();
while($row = mysql_fetch_array($rsLanguages)){
$languages_array[] = "\"".$row['language_sign']."\"";
}
$languages_string = implode(",", $languages_array);
if (in_array($lang, $languages_string)) {
echo 'found' ;
}
?>
正確的答案,謝謝 –