<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index as $id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>
我检查并重试了很多东西,我只是没有弄错。
答案 0 :(得分:10)
foreach ($ids as $index as $id)
应该是:
foreach ($ids as $index => $id)
答案 1 :(得分:2)
这是错误的:
foreach ($ids as $index as $id)
这不是正确的语法,你没有在任何地方使用$index
。只需使用:
foreach ($ids as $id)
答案 2 :(得分:0)
您 foreach
是错误的。试试这样吧。 键 - 值对用于表示此运算符 =>
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index=>$id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>
答案 3 :(得分:0)
正确的代码
<?php
include('database.class.php');
$sql = new Database(NULL);
$ids = $sql->select('*', '`ids` ORDER BY `UserId` ASC', NULL, NULL, NULL, true, true);
$dump = array();
foreach ($ids as $index => $id)
$dump[] = $id['UserId'].' | REGLINK - http://xat.com/web_gear/chat/register.php?UserId='.$id['UserId'].'&k2='.$id['k2'].'&mode=1';
$DumpFile = 'ids.txt';
if(file_exists($DumpFile)) {
unlink($DumpFile);
}
file_put_contents($DumpFile, implode("\r\n", $dump));
die(count($dump).' ids were dumped into the list.'."\n");
?>