0

I have the following code:

<?php
if ( isset($_POST['submit']) )
{
    // print_r($_POST['row']); // Works perfectly
    echo $_POST['row[1][2]'];
}
?>


<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php 
$num_of_days_in_month=3;
for($i = 1; $i<= $num_of_days_in_month; $i ++) {
for($j = 1; $j <= 4; $j++) {
echo "<input type=\"text\" name=\"row[$i][$j]\" />";
if ($j ==4) {
    echo "<br>";
}
}
}
?>
<input type="submit" name="submit" />
</form>

I am trying to echo row 1, column 2 and the output is blank.

Anyone know why?

Thanks, Jim

1
  • If you like to see what came through $_POST just dump all ... with ; echo "<pre>".vardump($_POST)."</pre>"; Commented Nov 22, 2012 at 14:51

2 Answers 2

2

Try this

echo $_POST['row'][1][2];

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

Comments

1

Your indexing is wrong, try this

<?php
if ( isset($_POST['submit']) )
{
    echo $_POST['row'][1];
    echo $_POST['row'][2];
}
?>

Or

<?php
if ( isset($_POST['submit']) )
{
    echo $_POST['row'][1][2];
}
?>

3 Comments

Positive answered first so I gave it to him/her.
@jimdif I answered first, check the time :)
@Mr.Alien: Yes, you answered first but you put the correct answer after mine. Thanks anyway

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.