access array in views

#1
[eluser]newbie110[/eluser]
I am trying to pass an array to the view of the very same controller. Here is my function
Code:
function show_menu(){
     $data['to_do_list']= array('Browse Jobs'=>'browse-jobs',
           'Browse companies'=>'browse-companies',
           'Categories'=>'categories',
           'Job Types'=>'job-types',
           'Salary Range'=>'salary-range',
           'Locations'=>'locations',
           'Packages'=>'packages',
           'Orders'=>'categories',
           'Contacts'=>'contacts');


   echo "Show Menu";
   $this->load->view('recruitment/admin_menu');
How can I access this $data in recruitment/admin_menu.php

#2
[eluser]CroNiX[/eluser]
First, you need to pass it to your view.
Code:
$this->load->view('recruitment/admin_menu', $data);

Then, CI runs extract() on $data, so in your view, you would access it by using $to_do_list, which is your array. So in your view, if you did
Code:
<?php print_r($to_do_list); ?>
You should see it.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.