-1

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?

John Conde
  • 217,595
  • 99
  • 455
  • 496
wzieba
  • 414
  • 2
  • 6
  • 21

2 Answers2

3

String concatenation rules apply even when used as array keys:

if (isset($_POST['is'.$i.'ID']))
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

Simply concat your strings. You even do it in your echo call :)

if (isset($_POST['is' . $i . 'ID']))
Ota
  • 696
  • 3
  • 11