php for loop variable names

后端 未结 5 1490
北恋
北恋 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:59

    As far as I am aware using different variable names is not possible.

    However if you uses arrays so as below

    $xm[3] = "";
    $xm[2] = "";
    $xm[1] = "";
    $xm[0] = "";
    

    or just $xm[] = "";

    Then you can use a for each loop:

    foreach($xm as $v) { echo $v; }
    

    Edit: Just Googled and this is possible using variable names but is considered poor practice. Learn and use arrays!

提交回复
热议问题