是否可以在$ _POST ["数组"] {input1},{input ...}中获取一系列信息

时间:2017-08-09 14:05:26

标签: php arrays

我正在寻找一种方法来做那样的事情

if ($_SERVER["REQUEST_METHOD"] == "POST") 
{
    if (isset($_POST["array"])) //Reset Button
    {
        print_r($_POST["array"]); //Able to print all the "whatever"Value below
    }
}

来自像这样的HTML代码

<form name="array" method="post" action="W3schoolTest.php">
     <?php
            foreach ($columnsList as $column) {
                echo $column.' : ';
                echo '<input type="text" name="'.$whateverItShouldBeFind.'"><br />'; 
            }
            echo '<br /><input type="submit"/>';
     ?>
</form>

我知道我可以在$_SESSION注册我的whateverValue名称,但我正在寻找合适的方法。

谢谢!

1 个答案:

答案 0 :(得分:1)

是的,应该可以使用以下符号:

对于POST:

$directory = get_bloginfo('template_directory')."/images/myImages/";
$images = glob($directory . "*.svg");
echo '<pre>';
print_r($images);
echo '</pre>';
echo $directory.'abnamro.svg">';
foreach($images as $image)
    {
      echo $image;
    }

在服务器上:

<input type="text" name="array[]" value="1" />
<input type="text" name="array[]" value="2" />
<input type="text" name="array[]" value="some-text" />

应该产生如下内容:

var_dump($_POST);

对于GET: 该URL应如下所示:

http://example.com?array[]=1&array[]=2&array[]=some-text