PHP函数从数组中打印数据


PHP function print data from array

我需要编写一个php函数,该函数将以下数组中的数据打印为HTML无序列表,其中包含超链接,其中"title"项作为链接副本,"path"项为链接的href,"class"数组中的项作为这些链接的类。

$mymenu = array(
   0 => array(
      'path' => 'all',
      'title' => 'All Content',
      'attributes' => array(
        'class' => array('first-item', 'menu-item'),
        ),
      ),
   1 => array(
      'path' => 'videos',
      'title' => 'Videos',
      'attributes' => array(
        'class' => array('item', 'menu-item'),
        ),
      ),
   2 => array(
      'path' => 'articles',
      'title' => 'Articles',
      'attributes' => array(
        'class' => array('last-item', 'menu-item'),
        ),
      ),
);

以下是我所拥有的,我认为属性有问题:

foreach($mymenu as $item) {
echo '<a href=' . $item['path'] . 'class="' . $item['attributes'] . '" />' . $item['title'] . '</a> <br>';
}

这似乎奏效了:

foreach($mymenu as $item) {
echo '<a href="'.$item['path'].'"class="'.$item['attributes']['class'][0] . ' ' .$item['attributes']['class'][1].'" />' . $item['title'] . '</a> <br>';  
}