[eluser]Walter Coots[/eluser]
I'm stumped. I'm defining a function in my view which is trying to access a variable passed from the controller. The function itself returns an error as if the variable isn't defined. However if I print_r() the variable outside of that function, it shows up as expected.
In my controller:
Code:
function constructAndShowToolbar()
{
$toolbarLinks['new'] = Array();
$toolbarLinks['edit'] = Array();
$toolbarLinks['system'] = Array();
$toolbarLinks['groupings'] = $this->TableOptions_model->getTableGroups();
/* [...] Code to populate the empty arrays */
$this->load->view('skins/admin/toolbar',$toolbarLinks);
}
Then in my view:
Code:
function createTopLevelMenu($arr,$title='UNTITLED')
{
if($groupings != NULL) /* Returns, "PHP Error- undefined variable: "groupings" */
{
print_r($groupings);
}
}
print_r($groupings); /* Prints the array in its entirety */
createTopLevelMenu($new,'New');
createTopLevelMenu($edit,'Edit');
createTopLevelMenu($system,'System');
}