【发布时间】:2016-06-17 10:06:59
【问题描述】:
全部!
所以,我有这个代码:
<?php
$clienthwid = $_POST["clienthwid"];
$clientip = $_POST["clientip"];
$hwid_logs = "hwid_log.txt";
$ip_logs = "ip_log.txt";
$handle_ip = fopen($ip_logs, 'a') or die("404 file not found");
$handle_hwid = fopen($hwid_logs, 'a') or die("404 file not found");
$client_whitelist = array (
// put hwids and ip here
"hwid" => "123456789", "12345678",
"ip" => "123.456.789", "123.456.788",
);
//check if client hwid or ip is in the array
if (in_array($clienthwid, $client_whitelist)) {
echo "TRUE";
fwrite($handle_hwid, $clienthwid."\n");
fwrite($handle_ip, $clientip."\n");
} else {
echo "FALSE";
fwrite($handle_hwid, $clienthwid."\n");
fwrite($handle_ip, $clientip."\n");
}
?>
所以,对于
in_array($clienthwid, $client_whitelist);
我想知道怎么做
in_array($clienthwid and $clientip, $client_whitelist)
如何检查两个变量是否在一个数组中?
【问题讨论】:
-
您的客户端白名单数组的格式是否正确?它不应该有子数组来分组 hwid 和 ip 值吗?
-
this的可能重复