Welcome Guest, Not a member yet? Register   Sign In
passing an array to a view
#3

[eluser]jedd[/eluser]
Hi obay,

Convention tends to be that you send $data to your view .. not enforced or required of course, but you'll often see people using it to wrap up other variables, including arrays, with the same intent that you have here.

So instead of what you're currently doing:

Quote:
Code:
$user_levels = $this->User_model->get_user_levels();
$this->load->view('user_create_view', array("user_levels" => $user_levels));

... you could instead just do this:

Code:
$data['user_levels'] = $this->User_model->get_user_levels();
$this->load->view('user_create_view', $data);

It means that anything else you want to use while in your user_create_view can just be whanged into a $data['xyz'] construct the same way.


Messages In This Thread
passing an array to a view - by El Forum - 08-11-2009, 09:32 PM
passing an array to a view - by El Forum - 08-11-2009, 10:21 PM
passing an array to a view - by El Forum - 08-12-2009, 06:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB