The passage in the foreach

Hugilore111

Member
Hi!
I have a multi-dimensional array.
How to take a category from the array?
Foreach does not work:(
Code:
array(10)
{
["categories"] => array(2) {
    [2] => array(7) {
      ["category_id"] => int(1)
      ["user_id"] => int(0)
      ["category_name"] => string(20) "Category"
      ["parent_id"] => int(0)
    }
    [4] => array(7) {
      ["category_id"] => int(4)
      ["user_id"] => int(0)
      ["category_name"] => string(20) "Category"
      ["parent_id"] => int(0)
         
    }
  }
}
 
Seeing the code you're using and what you're trying to do would help as based on what you've shown $var['categories'] has the data you want, so you'd either loop through that or pull by the ID ($var['categories'][2]).
 
Seeing the code you're using and what you're trying to do would help as based on what you've shown $var['categories'] has the data you want, so you'd either loop through that or pull by the ID ($var['categories'][2]).
Thank you.
We need more help
In one cycle is displayed breadcrumbs
how to get the category and subcategory

Code:
["categories"] => array(2) {
    [2] => array(7) {
      ["category_id"] => int(1)
      ["user_id"] => int(0)
      ["category_name"] => string(20) "Category"
      ["parent_id"] => int(0)
    }
    [4] => array(7) {
      ["category_id"] => int(4)
      ["user_id"] => int(0)
      ["category_name"] => string(20) "Category"
      ["parent_id"] => int(0)
       
    }
  }



Code:
<xen:foreach loop="$Cat" value="$v" key="$k" i="$i">
<xen:navigation>
    <xen:breadcrumb href="{xen:helper link, $v}">$v.category_name</xen:breadcrumb>
</xen:navigation>

</xen:foreach>
 
When I want to go in a foreach
to add a category and subcategory in the breadcrumbs
Code:
<xen:foreach loop="$array" value="$e" key="$k"  count="$count" >
<xen:navigation>
    <xen:breadcrumb href="{xen:helper link, $e}">{$e.category_name</xen:breadcrumb>
</xen:navigation>
</xen:foreach>
added only one
Where is my wrong?
 
Back
Top Bottom