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 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");
?>

私は多くのことを確認して再試行しましたが、何が間違っているのかわかりません。

4

4 に答える 4

13
foreach ($ids as $index as $id)

次のようにする必要があります。

foreach ($ids as $index => $id)
于 2013-09-21T06:01:27.663 に答える
2

これは間違っています:

foreach ($ids as $index as $id)

$indexそれは適切な構文ではなく、どこにも使用していません。これを使用するだけです:

foreach ($ids as $id)

foreachのマニュアルページを参照してください

于 2013-09-21T06:01:35.647 に答える
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");
?>
于 2013-09-21T06:01:46.670 に答える
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");
?>
于 2013-09-21T06:02:23.950 に答える