Create a menu programmatically in Drupal 7 A newbie question guys. 

Any thoughts how can I create a menu programmatically? Says I have 3 different menus I want to create. The first menu will be placed in the top left of the header. The second menu will be placed below the first menu. The third menu will be the main navigation.

Could these the menus be under the same group? Would it be a problem in styling?

Thanks
If you are trying to do this in an update script, this should work:

$menus = array(
  array(
    'menu_name' =&gt; 'menu_test_one',
    'title' =&gt; 'My Menu One',
    'description' =&gt; 'Lorem Ipsum',
  ),
  array(
    'menu_name' =&gt; 'menu_test_two',
    'title' =&gt; 'My Menu Two',
    'description' =&gt; 'Lorem Ipsum',
  ),
  array(
    'menu_name' =&gt; 'menu_test_three',
    'title' =&gt; 'My Menu Three',
    'description' =&gt; 'Lorem Ipsum',
  ),
);

$links = array(
  array(
    array(
      'link_title' =&gt; 'Link1',
      'link_path' =&gt; 'http://yourdomain.com/link1',
      'menu_name' =&gt; 'menu_test_one',
      'weight' =&gt; 0,
      'expanded' =&gt; 0,
    ),
    array(
      'link_title' =&gt; 'Link2',
      'link_path' =&gt; 'http://yourdomain.com/link2',
      'menu_name' =&gt; 'menu_test_one',
      'weight' =&gt; 1,
      'expanded' =&gt; 0,
    ),
  ),
  array(
    array(
      'link_title' =&gt; 'Link3',
      'link_path' =&gt; 'http://yourdomain.com/link3',
      'menu_name' =&gt; 'menu_test_two',
      'weight' =&gt; 0,
      'expanded' =&gt; 0,
    ),
    array(
      'link_title' =&gt; 'Link4',
      'link_path' =&gt; 'http://yourdomain.com/link4',
      'menu_name' =&gt; 'menu_test_two',
      'weight' =&gt; 1,
      'expanded' =&gt; 0,
    ),
  ),
  array(
    array(
      'link_title' =&gt; 'Link5',
      'link_path' =&gt; 'http://yourdomain.com/link5',
      'menu_name' =&gt; 'menu_test_three',
      'weight' =&gt; 0,
      'expanded' =&gt; 0,
    ),
    array(
      'link_title' =&gt; 'Link6',
      'link_path' =&gt; 'http://yourdomain.com/link6',
      'menu_name' =&gt; 'menu_test_three',
      'weight' =&gt; 1,
      'expanded' =&gt; 0,
    ),
  ),
);

// Save menu group into menu_custom table
foreach ($menus as $menu) {
  // Look the table first if the data does exist
  $exists = db_query("SELECT title FROM {menu_custom} WHERE menu_name=:menu_name", array(':menu_name' =&gt; $menu['menu_name']))-&gt;fetchField();
  // Save the record if the data does not exist
  if (!$exists) {
    menu_save($menu);
  }
}

$item = ''; 
foreach ($links as $layer1) {
  foreach ($layer1 as $link) {
    // Build an array of menu link 
    $item = array(
      'link_path' =&gt; $link['link_path'],
      'link_title' =&gt; $link['link_title'],
      'menu_name' =&gt; $link['menu_name'],
      'weight' =&gt; $link['weight'],
      'expanded' =&gt; $link['expanded'],
    );
    // Look the table first if the data does exist
    $exists = db_query("SELECT mlid from {menu_links} WHERE link_title=:link_title AND link_path=:link_path", array(':link_title' =&gt;  $link['link_title'], ':link_path' =&gt; $link['link_path']))-&gt;fetchField();
    // Save the record if the data does not exist
    if (!$exists) {  
      menu_link_save($item);
    }
  }
}


Comments are welcome if my approach is wrong. Thanks.