2010-04-02 71 views
0

例如:是否有可能在PHP中延遲變量實現(?)/承認(?)?

a.php只會(配置文件):

<?php 
$a = array('name'=>'wine[$index][name]', 
      'value'=>'wine[$index][value]' 
     ) 
?> 

B.php:

include_once(a.php) 
... 
//for simple 
$index = 0; 
$b = $a; 

//actual code like 
foreach($data as $index=>$value) 
    $b += $a 

我知道這個例子將無法正常工作,只是爲了交代,我想要是否有可能(如果可能的話,怎麼做?)在$ b = $ a時延遲變量$ index來取值?

+0

@Relax爲$ B = $一個與$ b等於$ a或你要爲$ B與$ a的值? – 2010-04-02 17:21:25

+0

後者,實際代碼就像foreach($ data爲$ index => $ value)$ b + = $ a – Edward 2010-04-03 03:44:39

回答

2

使 「一」 的功能

function a($index) { global $data; return $data[$index] ... } 

$b = a($index); 
+0

不是全球性的壞事嗎? – 2010-04-02 15:31:02

相關問題