Welcome Guest, Not a member yet? Register   Sign In
Foreach loop in controller
#1

[eluser]rvillalon[/eluser]
How do I run a foreach loop to change the values of an array before I send it out to the view for displaying?

I pass an array to my viewer as follows:
$data['product_list'] = $this->products_model->get_products($data['user_id']);
$this->load->view('admin/products/index', $data);

Then I run a foreach loop.

However, I want to change the value of all the $data['product_list']['id'] before I send it off. How would I go about doing that?

I tried the following, but can't seem to get it to work:

foreach($data['product_list'] as $product) {
$product['id'] = 1;
}


Messages In This Thread
Foreach loop in controller - by El Forum - 09-01-2009, 11:33 AM
Foreach loop in controller - by El Forum - 09-01-2009, 11:40 AM
Foreach loop in controller - by El Forum - 09-01-2009, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB