За последние 24 часа нас посетили 89659 программистов и 4387 роботов. Сейчас ищут 2173 программиста ...

Доступ к многомерному массиву

Тема в разделе "PHP для новичков", создана пользователем oslayer, 23 окт 2012.

  1. sobachnik

    sobachnik Старожил

    С нами с:
    20 апр 2007
    Сообщения:
    3.372
    Симпатии:
    13
    Адрес:
    Дмитров, МО
    Попробуй так:
    Код (PHP):
    1. private function getCategory($id_category, $id_lang = false, $id_shop = false, $curDepth = 1) {
    2.     $id_lang = $id_lang (int) $id_lang : (int) Context::getContext()->language->id;
    3.     $category = new Category((int) $id_category, (int) $id_lang);
    4.     if($category->level_depth > 1)
    5.         $category_link = $category->getLink();
    6.     else
    7.         $category_link = $this->context->link->getPageLink('index');
    8.  
    9.     if(is_null($category->id))
    10.         return;
    11.  
    12.     $children = Category::getChildren((int) $id_category, (int) $id_lang, true, (int) $id_shop);
    13.  
    14.     $selected = ($this->page_name == 'category' && ((int) Tools::getValue('id_category') == $id_category)) ? ' class="sfHoverForce"' : '';
    15.  
    16.     $is_intersected = array_intersect($category->getGroups(), $this->user_groups);
    17.  
    18.     // filter the categories that the user is allowed to see and browse
    19.     if(!empty($is_intersected) and $curDepth < 3) {
    20.         $this->_menu .= '<li class="alt1"' . $selected . '>';
    21.         $this->_menu .= '[url="' . $category_link . '"]name . '[/url]';
    22.         if(count($children)) {
    23.             $this->_menu .= '<div class="st"></div><ul class="level2">';
    24.             foreach ($children as $child)
    25.                 $this->getCategory((int) $child['id_category'], (int) $id_lang, (int) $child['id_shop'], $curDepth + 1);
    26.             $this->_menu .= '</ul>';
    27.         }
    28.         $this->_menu .= '</li>';
    29.     }
    Но вообще, никому не известно, как там всё устроено в твоей CMS...