0

How i can take the data from test[] on action.php file?

<form action="action.php" method="post">
<input type="text" name="test[]"><br />
<input type="text" name="test[]"><br />
<input type="submit" value="invia" />

i try this but don't work. How can I print an array in separate data?

echo $_POST["test"];
echo $_POST["test"];

1 Answer 1

5

You have to use the index to get the specific items:

echo $_POST["test"][0];
echo $_POST["test"][1];

Or output the array:

print_r($_POST["test"]);

Or loop over it:

foreach($_POST["test"] as $item) {
    echo $item;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.