借鉴:http://blog.sina.com.cn/s/blog_7193eeac0100zwld.html

如果想for循环生成变量

如: $a1,$a2,$a3....

$name = "test";                   //这一类的变量就是 test1,test2····
for($i=0; $i<3; $i++){
    ${$a.$i} = $i;               //把$a 和 $i 用{}括起来 然后前面放个$就OK啦
}
echo $a0;                        //0;
echo $a2;                       //2;

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-01
  • 2021-12-31
  • 2022-01-03
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案