This code in my case is not working properly when the size of the array does not correspond to the maximum key!huntkey wrote:Code: Select all
$last_items = array();//all last item IDs for($j=count($list); $j>0; $j--){ if(!isset($last_items[$list[$j]->parent_id])){ $last_items[$list[$j]->parent_id] = $list[$j]->id; } } $first_start = true;//using for first item of level 1 menu and submenu
For proper placement of the 'last' classes for menu items, I replaced the above code on such:
Code: Select all
$last_items = array();//all last item IDs
foreach ( array_reverse ( $list, TRUE ) as $v ) {
if ( !isset ( $last_items[$v->parent_id] ) )
$last_items[$v->parent_id] = $v->id;
}
$first_start = true;//using for first item of level 1 menu and submenu