PHP dynamically reference variable in string literal

前端 未结 1 665
清歌不尽
清歌不尽 2021-01-22 05:07

I have multiple PHP variables in the form

$number1, $number2, $number3 and so on...

I would like to dynamically reference these inside of a loo

相关标签:
1条回答
  • 2021-01-22 05:52

    This should do it:

    echo ${"number{$i}"};
    

    But why not use arrays instead? Having $number[$i] is much more readable...

    0 讨论(0)
提交回复
热议问题