-2

我有销售收费卡的网站,我使用此代码向客户销售他们验证手机号码,手动(每次添加一行)最近我使用 SMS 服务和存储在网站文本文件中的号码,如何删除这些行,我从 .txt 文件中得到数字?(txt文件中逐行存储的数字)

if ($data[mobile] AND !eregi("^09512362982$", $data[mobile]))
if ($data[mobile] AND !eregi("^09527415120$", $data[mobile]))
if ($data[mobile] AND !eregi("^09532247462$", $data[mobile]))
if ($data[mobile] AND !eregi("^09535241919$", $data[mobile]))
if ($data[mobile] AND !eregi("^09535716327$", $data[mobile]))
$error .= "Mobile number not valid, please verify your number<br />";
4

1 回答 1

0

您可以使用file将文本文件的内容读入一个数组,然后in_array查看该数字是否存在。

if (!in_array($_data['mobile'], file('your_text_file.txt', FILE_IGNORE_NEW_LINES))) {
    $error .= "Mobile number not valid, please verify your number<br />";
}
于 2016-10-07T20:12:01.743 回答