php for loop variable names

后端 未结 5 1429
北恋
北恋 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条回答
  •  走了就别回头了
    2021-01-21 01:49

    It is not fully clear what you are asking, but you can do

    $xm = 'xm3';
    $$xm // same as $xm3
    

    in PHP, so you can loop through variables with similar names. (Which does not mean you should. Using an array is usually a superior alternative.)

提交回复
热议问题