Search code examples
phpstringvariablespostarray-key

using variable in $_POST[]


I suppose that this is very noob question but I can't figure it out.

I've got code:

for($i=1; $i<9; $i++){

    if (isset($_POST['is'$i'ID'])) {
        echo $i . " is OK<br>"; 
    }


}

And I know that the problem lies in this line :

if (isset($_POST['is'$i'ID']))

How can I use variable i in this code?


Solution

  • String concatenation rules apply even when used as array keys:

    if (isset($_POST['is'.$i.'ID']))