duanjianhe1388 2017-03-13 00:36 采纳率: 100%
浏览 16
已采纳

是否可以在没有数组的循环中定义引用

im trying to make a reference to a multidimentional array columns, and i need to make an $i ammount of references to the array values as string. for example 1st row:

for ($i=0; $i<count($array[0][column[$i]]);$i++)
{
   $value_1 = &$array[0][column[$i]];
}

is there a way to name the "$value_x" variable with $i identificator? similar to echo "$value_$i"; im lacking experience with references, any advise would be appreciated.

  • 写回答

1条回答 默认 最新

  • douzhao2047 2017-03-13 00:50
    关注

    You can set multiple variables with a name based on the loop index with ${"value_$i"}:

    <?php
    
    for ($i=0; $i<10;$i++)
    {
       ${"value_$i"} = &$array[0][column[$i]];
    }
    

    I've created a working example showcasing this here :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法