我從文件中下載數據并將其保存到表中,然后我嘗試搜索數組并在表中寫入“找到匹配”,如果不寫入“未找到匹配”我的文件憑證.txtub65rf98huf4YbyR42我的代碼 PHP$array = [];$array = file('voucher.txt');$find = '98huf4';if (in_array($find, $array)) { echo "Match found"; }else { echo "Match not found"; }
1 回答

梵蒂岡之花
TA貢獻1900條經驗 獲得超5個贊
默認情況下file()
,字符串中包含換行符,因此它們與您的字符串不匹配$find
。有一個標志可以刪除它們。
$array = file('voucher.txt', FILE_IGNORE_NEW_LINES);
- 1 回答
- 0 關注
- 110 瀏覽
添加回答
舉報
0/150
提交
取消