1

I have an array of inputs similar to below

<input name="attr[]" value = "a" type="text" />
<input name="attr[]" value = "b" type="text" />
<input name="attr[]" value = "c" type="text" />

On the server side I am using a foreach loop to fetch the value entered. However, I want the values a ,b and c as well. How do i do that in PHP?

I did something like this but its not working for me. The $key returned is just an index.

foreach($_POST['attr'] as $key=>$val)
{
   //process each $key and $val
}
0

1 Answer 1

1

use this code for retrieving values

foreach($_POST['attr'] as $key=>$val)
{
   echo $val;
}
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.