(
[0] => stdClass Object
(
[id] => 101
[menutype] => mainmenu
[title] => MindPHP
[alias] => home
[note] =>
[path] => home
[link] => index.php?option=com_content&view=featured
[type] => component
[published] => 1
[parent_id] => 1
[level] => 1
[component_id] => 22
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[browserNav] => 0
[access] => 1
[img] =>
[template_style_id] => 0
[params] => {"featured_categories":[""],"layout_type":"blog","num_leading_articles":"0","num_intro_articles":"0","num_columns":"1","num_links":"0","multi_column_order":"1","orderby_pri":"","orderby_sec":"front","order_date":"","show_pagination":"0","show_pagination_results":"0","show_title":"","link_titles":"","show_intro":"","info_block_position":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_vote":"","show_readmore":"","show_readmore_title":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_hits":"","show_tags":"","show_noauth":"","show_feed_link":"1","feed_summary":"","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_text":1,"page_title":"","show_page_heading":"0","page_heading":"","pageclass_sfx":"","menu-meta_description":"","menu-meta_keywords":"","robots":"","secure":0}
[lft] => 11
[rgt] => 12
[home] => 1
[language] => *
[client_id] => 0
)
[1] => stdClass Object
(
[id] => 102
[menutype] => mainmenu
[title] => บทเรียนออนไลน์
[alias] => 2015-07-14-09-34-08
[note] =>
[path] => 2015-07-14-09-34-08
[link] =>
[type] => url
[published] => 1
[parent_id] => 1
[level] => 1
[component_id] => 0
[checked_out] => 0
[checked_out_time] => 0000-00-00 00:00:00
[browserNav] => 0
[access] => 1
[img] =>
[template_style_id] => 0
[params] => {"menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_text":1}
[lft] => 13
[rgt] => 46
[home] => 0
[language] => *
[client_id] => 0
)
)
โค้ด: เลือกทั้งหมด
$level = array();
foreach ($data as $key => $value) {
$level[] = $value->level;
$level_menu = array_unique($level); // หา level ของ menu ว่ามี level อะไรบ้าง
print_r($level_menu);
}
Array
(
[0] => 1
)
Array
(
[0] => 1
)
Array
(
[0] => 1
[2] => 2
)
Array
(
[0] => 1
[2] => 2
)
Array
(
[0] => 1
[2] => 2
)
Array
(
[0] => 1
[2] => 2
)
Array
(
[0] => 1
[2] => 2
)