2

Possible Duplicate:
PHP: How to remove specific element from an array?

Here in my $_POST, I am quite confused on how to trim or drop the key 'submit'. I'm quite confused with this array manipulation. Thanks.

Array
(
    [Physical_Education] => 43
    [Statistics] => 34
    [Biology] => 43
    [Math] => 34
    [quarter] => 1
    [submit] => Submit Grades
)
5
  • 3
    Why do you need to remove the key anyways? Commented Dec 9, 2011 at 1:32
  • 4
    The $_POST array itself isn't really meant to be manipulated. Any information you get from it should be taken out of the array and put into variables or another array; it's better coding practice. Commented Dec 9, 2011 at 1:33
  • What is so weird about unsetting properties in an associative array? JavaScript dedicates a whole keyword to it (delete) - ah but yes, $_POST is a global thing, don't mess with it too much. Commented Dec 9, 2011 at 1:34
  • Thanks for the insights about this. Commented Dec 9, 2011 at 1:34
  • i'm so confused as to why it even includes submit buttons and their values lol Commented Sep 12, 2017 at 4:07

3 Answers 3

14

Using unset() should do the trick:

unset($_POST['submit']);
Sign up to request clarification or add additional context in comments.

Comments

4

You can unset() the member, like Tim Cooper suggests.

However, if you don't want that being POST'd in the first place, you could drop the name attribute on your submit button.

Comments

1

Tackle the root of the problem!

It's in there because your submit button looks like this:

<input type="submit" name="submit" value="Submit Grades">

Thus, remove the name and it won't be sent:

<input type="submit" value="Submit Grades">

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.