我正在使用in_array
在數組中搜索數值。我的代碼如下:in_array函數未給出預期結果
$file = 'domains.txt'; //reading txt file
$lines = file($file);//file in to an array
if (in_array("yahoo.com", $lines)) {
echo "Got Domain";
}
但是,它不工作,只顯示空白頁,但yahoo.com是domains.txt可用,因此它應該返回true,但我還是堅持了下來,請大家幫忙, 謝謝。
您沒有錯誤檢查以確定您是否從文件中讀取任何內容。 – 2012-04-19 19:56:54