Welcome Guest, Not a member yet? Register   Sign In
How to return a array from Codeigniter Usermodel
#1

[eluser]Dileep[/eluser]
Hello there ,

I am returning a array from a usermodel.

Code:
function user()
{

.....
.....

$valarray = array('k'=>'z','m'=>'1');
return $valarray();
}

now how can i access this array in a controller ,i know it is a newbie question,please help me.
#2

[eluser]jblack199[/eluser]
if it's actually in an model you'd do it like this in your controller:

Code:
$this->load->model('model_name');
$whatever = $this->model_name->function();

which theoretically should work fine.

if it's in a helper however, it'd be more like:

Code:
$this->load->helper('helper_name');
$whatever = function();
#3

[eluser]OliverHR[/eluser]
You can use as normal var/array, like in any other php function.

In a function of your controller:
Code:
function my_function()
{
  $this->load->model('usermodel');

  $array = $this->usermodel->user();

  echo '<pre>';
  print_r($array);
  echo '</pre>';
}
#4

[eluser]Dileep[/eluser]
Thank you,its worked,+1BRO !!

SOLVED.




Theme © iAndrew 2016 - Forum software by © MyBB