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

[eluser]obay[/eluser]
Hi,

I am very new to CI, and I found out that when arrays are passed to views, the keys are converted to variables.

But I needed to pass an array to my view. So currently, this is my controller:

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

and my view:

Code:
User Level: <?=form_dropdown("level",$user_levels);?>

and it works. (By the way, $user_levels in my controller is an array)

I was just wondering if there was a better way to do this, as creating a new array to wrap my existing array $user_levels seemed,.. uhh.. redundant...

Any ideas?

Thanks


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