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++;
}
4

1 回答 1

2

在 PHP 中,您可以使用{$variable}内部的 "" 字符串,但它只能真正处理基本变量。改变它,就像这样:

echo $_POST['text_l' . $i] . ', ' . $_POST['l' . $i];
于 2013-05-27T15:30:03.700 回答