0

I have this piece of code where I need to output some $_POST values into HTML. Nothing happens in the output line (see comment inside the code), even though var_dump() shows that the needed values are in the array and under the desired indexes.

The trick is that the array indexes for the required data depend on the counter $i. I'm feeling like there is some really stupid and basic syntax mistake in this code. Please help me, oh almighty Hivemind!

while ($i < $somespecificvar) 
{ 
    if (($i != 0) AND ($i < $somespecificvar)) 
    {
        echo "\n<td></td>\n";
    }

    echo "<td>";

    if ($_POST["text_l$i"] != 0)
    {
        echo "{$_POST['text_l$i']}, {$_POST['l$i']}";// NOTHING HAPPENS OVER HERE
    }

    echo "</td>";
    $i++;
}

1 Answer 1

2

In PHP, you can use the {$variable} inside a "" string, however it can only really handle basic variables. Change it so it's like so:

echo $_POST['text_l' . $i] . ', ' . $_POST['l' . $i];
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Thanks, man! I've spent days on trying to fix this one!

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.