php排序器脚本只输出相同的数据,即使我要求它做不同的处理


php sorter script only outputting the same data even though i am asking it to do diffrent

好的,所以我制作了下面的脚本来以这种格式对我的一些数据进行排序

0|1|2

这是我的脚本(现在有效)

    <html>
<body>
    <form method="post">
<div align="center"><textarea name="mp" cols="60" rows="10">0|1|2</textarea><br />
Delim: <input type="text" name="delim" value="|" size="1" />&nbsp;data1: <input type="text" name="mail" value="0" size="1" />&nbsp;data2: <input type="text" name="pwd" value="1" size="1" />&nbsp;
<input type="submit" value=" send " name="btn-submit" />
</div>
</form>
</body>
</html>
<?php
    if (isset($_POST['mp'], $_POST['delim'], $_POST['btn-submit'], $_POST['mail'], $_POST['pwd'])) {
        $mps = preg_split('/'r'n|'r|'n/', $_POST['mp']);
        // Create an array to store results
        $result_data = array();
        // Iterate over requests
        foreach ($mps as $mp) {
            $mp = explode($_POST['delim'], $mp);
            // Store the account details in variables
            $email = $mp[$_POST["mail"]];
                  $password = $mp[$_POST["pwd"]];
            // Prepare a reusable string
            $result_string = "" . $email .  " : " . $password . "";
                            // Add result to the array
            $result_data[] = $result_string;



}
// Store of results complete. We now display them.
        if (count($result_data)) {
            echo "<ul
    list-style-type: none;
>";
            foreach ($result_data as $result_data_entry) {
                echo "<li list-style: none;>" . $result_data_entry . "</li>";
            }
            echo "</ul>";
        }
}


?>

我现在也想把结果保存到一个文本文件中任何帮助都是非常棒的。

我多写了这一行,因为我的帖子代码太多了。

您在PHP中的任何地方都没有使用data1和data2字段。

我认为不是这样:

list($email, $password) = $mp;

你需要

$email = $mp[$_POST["mail"]];
$password = $mp[$_POST["pwd"]];

同样值得注意的是,这两个字段中提供的值将以零为基础。