I'm trying to get my head around arrays. This a is a followup to previous question. PHP How can I pass values from one array to another?
So, I've figured out how to pass data from one array to another thanks to: Explosion Pills but now i'm trying to take the array and pass it through to a new function and then create the new array within the new function. I'm guessing this is easier than it appears to be to me right now.
Here is the array:
$theSetup = array(
'option1' => array('title'=>'my_title','label'=>'The Big Title','val'=>'NoneyoBizness'),
'option2' => array('title'=>'my_watch,'label'=>'Big Watch','val'=>'Seiko'),
'option3' => array('title'=>'facebook','label'=>'Facebook Page','val'=>'http://facebook.com/bigwatch'),
);
Here is my test function:
function testArray($theSetup) {
foreach($theSetup as $v) {
$defaultOptions[$v['title']] = $v['val'];
}
foreach($defaultOptions as $k=>$v) {
echo $k .' : '.$v .'<br>';
}
}
testArray($theSetup);
After running the code I get an error: undefined variable theSetup
$theSetup? If it is in a different scope/context PHP won't be able to find it.