smokyyyyyy Posted July 14, 2012 Share Posted July 14, 2012 HI i am new to progreamming and CodeIgniter I created a new function in CodeIgniter HTML_HELPER.PHP which can create menu when pass an array in function as parameter When i run the script it says A PHP Error was encountered Severity: Notice Message: Undefined index: menu Filename: helpers/html_helper.php Line Number: 445 A PHP Error was encountered Severity: Warning Message: Invalid argument supplied for foreach() Filename: helpers/html_helper.php Line Number: 447 A PHP Error was encountered Severity: Notice Message: Undefined variable: li_a_menu Filename: helpers/html_helper.php Line Number: 450 Following is my code kindly help me if ( ! function_exists('menu')) { function menu($menu=''){ $id=$menu['id']; $item= $menu ['menu']; $nav_menu='<div id ='."$id".'>'; foreach($item as $li_menu){ $li_a_menu[]='< a href ='.base_url().$li_menu.'>'.strtoupper(str_replace('_','',$li_menu)).'</a>'; } $nav_menu.=ul($li_a_menu).'</div>'; echo $nav_menu; } } I created the View navigtion.php i am calling it like this $data= array('id'=>'nav', array ('menu1' =>'home', 'menu2' =>'create_post', 'menu3' =>'contact', 'menu4' =>'about'), ); echo menu($data); It throws error message kindly help me please read the error message at the start of this post Quote Link to comment https://forums.phpfreaks.com/topic/265676-severity-notice-message-undefined-index-menu/ Share on other sites More sharing options...
gizmola Posted July 14, 2012 Share Posted July 14, 2012 The way your function works, your input array needs to be adjusted to this: $data = array('id'=>'nav', 'menu' => array ('menu1' =>'home', 'menu2' =>'create_post', 'menu3' =>'contact', 'menu4' =>'about'), ); Quote Link to comment https://forums.phpfreaks.com/topic/265676-severity-notice-message-undefined-index-menu/#findComment-1361546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.