Welcome Guest, Not a member yet? Register   Sign In
array is stripped when put foreach
#1

[eluser]Unknown[/eluser]
Hello!
I want to make "categories" and their "subcategories" - which I made in pure PHP but with CI I have some troubles.

I have one method get_cat() - which takes the categories, and one method get_subcat($sub) which takes the subcategories.
get_cat() gives me the all info for the categories and I pass it and use only category_id in get_subcat. Well, here is some code:

$data['cat'] = $this->Dbase->get_cat();
//moment 1
foreach($data['cat'] as $cat)
//moment 2
$data['sub'] = $this->Dbase->get_subcat($cat['category_id']);

moment 1 - all categories are there (print_r($data['cat']))
moment 2 - only the first category is there => only 1 id is passed to get_subcat and I get subcategories only for the first cat (print_r($cat))

I hope you understood and can help) Thanks a lot in advance.


Messages In This Thread
array is stripped when put foreach - by El Forum - 04-12-2011, 02:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB