How do I use theme('links') with nested arrays? I want to render the following output:

&lt;ul&gt;
  &lt;li&gt;&lt;a href='url1'&gt;link 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href='url2'&gt;link 2&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href='url3'&gt;sub-link 3&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href='url4'&gt;link 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


I was expecting this to be pretty straightforward:

$list = array(
  'item1' =&gt; array('title' =&gt; 'link 1', 'href' =&gt; 'url1'),
  'item2' =&gt; array(
    'title' =&gt; 'link 2', 'href' =&gt; 'url2',
    array(
      'item3' =&gt; array('title' =&gt; 'sub-link 3', 'href' =&gt; 'url3'),
    ),
  ),
  'item4' =&gt; array('title' =&gt; 'link 4', 'href' =&gt; 'url4' ),
);

$output = theme('links', array('links' =&gt; $list));


This outputs the following however, ignoring item3:

&lt;ul&gt;
  &lt;li&gt;&lt;a href='url1'&gt;link 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href='url2'&gt;link 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href='url4'&gt;link 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
You need to add the sub items to a 'children' key of the array. Here is an example:

$list = array(
  'item1' =&gt; t('Item 1'),
  'item2' =&gt; array(
    'data' =&gt; t('Item 2'),
    'children' =&gt; array(
      t('Item 3'),
    ),
  ),
  'item4' =&gt; t('Item 4'),
);

return theme('item_list', array('items' =&gt;  $list));