views:

54

answers:

1

For example:

A.php (the config file):

<?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

I know this example won't work, just for explaination, i wanna if it is possible (if possible, how?) to delay variable $index to take value when $b = $a ?

+1  A: 

make "a" a function

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

 $b = a($index);
stereofrog
Isn't global a bad thing?
Brant