CodeIgniter Forums

Full Version: Need Help for accessing array in view files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Mistry007[/eluser]
Hi i am having trouble while accessing array in view file.
Can any one help me out?? I have define one array in view file and i want to access it in my function but it will give me Fatal error: Using $this when not in object context.
Here is my view code.

$menu_array = array();
foreach ($category as $rowdata)
{

$this->menu_array[$rowdata->category_id] = array(
'id' => $rowdata->category_id,
'category' => $rowdata->category_master_name,
'parent_id' => $rowdata->category_parent_id);
}
generate_menu(0);
function generate_menu($parent)
{
print_r($this->menu_array);
}

Thanks.