1

I have got a question regarding printing an array of checkboxes in the $_POST When I do:

echo '<pre>';
print_r($_POST);
echo '</pre>';

I can see the Checkboxes which I send through the $_POST How am I able to read only the checkboxes? This is what I currently have:

print_r($_POST['checkboxes[]']);

But this doesn't seem to work

5
  • 2
    $_POST['checkboxes'] Commented Apr 20, 2018 at 14:15
  • 1
    If the name of the input is in fact checboxes, remove the squares [] Commented Apr 20, 2018 at 14:16
  • Your dealing with the field names and not their types. Commented Apr 20, 2018 at 14:16
  • I don't know why, but this didn't solve the problem in first place. Probably some cache? it however did now. Thank you very much!! @BartScheffer Commented Apr 20, 2018 at 14:17
  • if you variable is array, dont include '[]' on POST like this $_POST['checkboxes'] Commented Apr 20, 2018 at 14:18

1 Answer 1

1

If your checkboxes actually have their name='checkboxes[]', then you can access their POST value by doing print_r($_POST['checkboxes']);. You do not have to include the square brackets when referencing the name of the POST value, the brackets are only there make all of the same named elements post as an array.

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.