1

I have a form in HTML, and it stores data into array structure.

echo '<input type="text" style="text-align:right;" size="5" name="row[1][kidname]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[1][kidweight]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[1][kidheight]" />';

echo '<input type="text" style="text-align:right;" size="5" name="row[2][kidname]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[2][kidweight]" />';
echo '<input type="text" type="number" style="text-align:right;" size="5" name="row[2][kidheight]" />';

Supposed I need to get the second kid's weight value, how should I do? I have tried:

$_POST[row[2][kidweight];

$_POST['row[2][kidweight'];
5
  • 4
    $_POST['row'][2]['kidweight']; Commented Nov 10, 2018 at 4:47
  • 1
    Hi thanks for your fast reply, if I want to change it to index ( i ) , will it looks like this ? $_POST['row'][$i]['kidweight']; Commented Nov 10, 2018 at 5:04
  • thanks Scuzzy it's working ! just some additional information I have changed it to index : $_POST['row'][$i]['kidweight']; Commented Nov 10, 2018 at 5:11
  • 1
    Yep, or you can do foreach( $_POST['row'] as $key => $row ){ echo $value['kidweight']; } Commented Nov 10, 2018 at 5:17
  • great ! thanks Scuzzy for your info Commented Nov 10, 2018 at 6:55

1 Answer 1

1

You can try also.

$_GET['row'][2]['kidweight'];
Sign up to request clarification or add additional context in comments.

1 Comment

get? the OP said post

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.