php数组有问题。我正在尝试发送带有写入 $variable 数组的路径的 get_headers() 请求,回答我想写入 MySQL 数据库,已经花了几个小时,但没有找到如何做到这一点。它只返回 1 个结果,但如果 echo 结果来自数组 - 例如可以看到 3 个结果。请帮帮我:)
foreach($array_variable as $variable) {
$url = "http://".$site.$variable;
$file_headers = @get_headers($url);
if($file_headers[0] == 'HTTP/1.1 200 OK') {
$test = $url;
echo $test; //here it works fine, I can see all available results
$sql = mysql_query("INSERT INTO table (col_1, col_2) VALUES ($smthing, $test)"); //here problem is that result duplicates many-many times
}
echo $test; //but here I have problems, can see only 1 result (last one)
$sql = mysql_query("INSERT INTO table (col_1, col_2) VALUES ($smthing, $test)"); //here problem is, only 1 result goes to our database