0
http://pastebin.com/MFCQzJQ8

我有这段代码,我正试图让它输出结果

echo $attack.' Attacks Have Been Stopped On Server '.$id.'<br>';

每次都不同,但我只能更改服务器 ID 或攻击,但我每次都需要更改并在新行上输出。

http://gyazo.com/f38c20ecef5af72dcc534be88101f8a2

    <?php
    if (isset($_POST['stop']))
    {
        $ids = $_POST['id'];
        $urls = $_POST['url'];
        $attacks = $_POST['attack'];
        foreach($urls as $url);
        foreach($attacks as $attack);
        foreach($ids as $id);


            echo '<div class="nNote nSuccess hideit"><p><strong>SUCCESS: </strong><br>';

            foreach($ids as $id){
            if($attack == "NONE"){$attack = "No";}
            echo $attack.' Attacks Have Been Stopped On Server '.$id.'<br>';
            }
            echo '</p></div>';
    }
    ?>
4

1 回答 1

1

您可以将数组合并为一个并对其进行迭代:

foreach(array_map(null,$ids,$urls,$attacks) as list($id,$url,$attack)) {
    // code body here
}
于 2013-04-02T00:54:48.807 回答