php for loop variable names

后端 未结 5 1477
北恋
北恋 2021-01-21 01:22

i got a code of 100-200 rules for making a table. but the whole time is happening the same. i got a variable $xm3, then i make a column . next row, i got $xm2 and make column. n

5条回答
  •  Happy的楠姐
    2021-01-21 01:46

    You can do this using variable variables, but usually you're better off doing this sort of thing in an array instead.

    If you're positive you want to do it this way, and if 'y' is the value of your counter in the for loop:

    ${'xm' . $y} = $someValue;
    

提交回复
热议问题