CodeIgniter Forums
Need Help for accessing array in view files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Need Help for accessing array in view files (/thread-45906.html)



Need Help for accessing array in view files - El Forum - 10-10-2011

[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.