1

I feel like I am going crazy. I have submitted the following POST request containing these inputs:

...
<textarea type='text' name='description["add"]></textarea>
<textarea type='text' name='description["modify"]></textarea>
<textarea type='text' name='description["delete"]></textarea>
...

When I print them out using print_f($_POST), this is the output:

[description] => Array
        (
            ["add"] => blah blah blah
            ["modify"] => bleh bleh bleh
            ["delete"] => bloh bloh bloh
        )

I want to access the text in ["add"]. I try print_r($_POST['description']['add'] but it keeps returning nothing!

How can I access the deeper levels of the $_POST array? Everything I thought I knew about php is wrong!

I have tried other formats like $_POST['description']->add and $_POST['description'][0]. Both return nothing.

The only way I thing that I found works is iterating using a foreach.

foreach ($_POST['description' as $value) {
     print_r($value);
}

What am I missing? Please help!! I'm going insane. Thank you

Paul Trimor
  • 320
  • 3
  • 15

1 Answers1

2

The quotes in the HTML array index here ["add"] are adding actual quotes to the index in PHP, so you would need $_POST['description']['"add"'].

Don't use quotes in the HTML array index name='description[add]', then this works $_POST['description']['add'].

Also, make sure to use the closing quote around the name 'description[add]'.

AbraCadaver
  • 78,200
  • 7
  • 66
  • 87