-1

I am using this code but can't figure out what's wrong with it.

if (!empty($_POST)) {
    foreach ($_POST as $key => $value) {
        if (get_magic_quotes_gpc()) 
            $value=stripslashes($value);
        if ($key=='extras') {       
            if (is_array($_POST['extras'])) {
                print "<tr><td><code>$key</code></td><td>";
                foreach ($_POST['extras'] as $value) {
                print "<i>$value</i><br />";
                }
                print "</td></tr>";
                } 
            else {
                print "<tr><td><code>$key</code></td><td><i>$value</i></td></tr>\n";
                }
            } 
        else {
            print "<tr><td><code>$key</code></td><td><i>$value</i></td></tr>\n";
        }
    } // end foreach
}

It prints prgm 'array' in table instead of values inside array.

4
  • 2
    stackoverflow.com/questions/6398623/… Commented Oct 13, 2013 at 16:56
  • @u_mulder I think it's not going inside if (is_array($_POST['extras'])) Commented Oct 13, 2013 at 17:32
  • Then find out where it happens Commented Oct 13, 2013 at 18:08
  • it's going inside else, I'm not able to figure it out, please help Commented Oct 13, 2013 at 20:16

1 Answer 1

2

I feel like using print_r() would be at least a way to gain some insight into the structure of the array.

Sign up to request clarification or add additional context in comments.

5 Comments

I think it's not going inside if (is_array($_POST['extras']))
print_r is definitely your friend here!
this is not working, please help!!
@user2876449 : could you maybe post how you are attempting to use print_r()? I would first just call print_r($_POST) to see the structure of the POST array.
this worked when i changed if (is_array($_POST['extras'])) to if (is_array($value))

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.