php:数组项设置为另一个数组项(兄弟)

Zeb*_*bra 0 php arrays key

数组中的项"引用"设置为$array['fruit'].但没有回报价值

$array = array(
          'fruit'=>'apple',
          'reference'=>$array['fruit']
         );
Run Code Online (Sandbox Code Playgroud)


例: echo $array['reference']; //the word apple should be displayed



这个结果是如何实现的?

Chr*_*isR 8

你实际上是在引用$ array变量时创建它,所以它是正常的,它什么都不包含.

这可行,但说实话,你正在做的事情有点粗略.

$array = array('fruit' => 'apple');
$array['reference'] = $array['fruit'];
Run Code Online (Sandbox Code Playgroud)