Display PHP Menu Stored in an Array and Looped
I'm not sure for optimization but for readability and maintenance I would use a Class and create the menu items as objects instead of multi-dimension arrays.

class MenuItem {

  protected $id;
  protected $name;
  protected $url;
  protected $level;
  protected $seq;
  protected $under;
  protected $target;
  protected $display;

  public function __construct($name, $url, $id, $level, $seq, $under, $target, $display) {
    $this-&gt;id = $id;
    $this-&gt;name = $name;
    $this-&gt;url = $url;
    $this-&gt;level = $level;
    $this-&gt;seq = $seq;
    $this-&gt;under = $under;
    $this-&gt;target = $target;
    $this-&gt;display = $display;
  }

  public function getId() {
    return $this-&gt;id;
  }

  public function getName() {
    return $this-&gt;name;
  }

  public function getUrl() {
    return $this-&gt;url;
  }

  public function getLevel() {
    return $this-&gt;level;
  }

  public function getSeq() {
    return $this-&gt;seq;
  }

  public function getUnder() {
    return $this-&gt;under;
  }

  public function getTarget() {
    return $this-&gt;target;
  }

  public function getDisplay() {
    return $this-&gt;display;
  }

}


And so your creation code would become:

$siteURL = "http://www.mysite.org/";

$menu = array
   (
   //"Name","URL",ID,Level,Seq,Under,Target,Display
   //First Menu
   new MenuItem("TOP1",$siteURL."top1.php",1,1,1,0,0,true),
   new MenuItem("SUB1a",$siteURL."sub1a.php",2,2,1,1,0,true),
   new MenuItem("SUB1b",$siteURL."sub1b.php",3,2,2,1,0,true),
   new MenuItem("SUB1c",$siteURL."sub1c.php",4,2,3,1,0,true),
   new MenuItem("SUB1d","http://www.externalsite.org/",5,2,4,1,1,true),
   new MenuItem("SUB1e","http://www.externalsite.org/",6,2,5,1,1,true),
   new MenuItem("SUB1f",$siteURL."sub1f.php",7,2,6,1,0,true),

   //Second Menu
   new MenuItem("TOP2",$siteURL."top2.php",8,1,2,0,0,true),
   new MenuItem("SUB2a","http://www.externalsite.org/",9,2,1,8,1,true),
   new MenuItem("SUB2b",$siteURL."sub2b.php",10,2,2,8,0,true),
   new MenuItem("SUB2c","http://www.externalsite.org/",11,2,3,8,1,true),
   new MenuItem("SUB2d","http://www.externalsite.org/",12,2,4,8,1,true),

   //Third Menu
   new MenuItem("TOP3",$siteURL."top3.php",13,1,3,0,0,true),
   new MenuItem("SUB3a","http://www.externalsite.org/",14,2,1,13,1,true),
   new MenuItem("SUB3b","http://www.externalsite.org/",15,2,2,13,1,true),
   new MenuItem("SUB3c","http://www.externalsite.org/",16,2,3,13,1,true),
   new MenuItem("SUB3d","http://www.externalsite.org/",17,2,4,13,1,true),

   //Fourth Menu
   new MenuItem("TOP4",$siteURL."top4.php",18,1,4,0,0,true),
   new MenuItem("SUB4a",$siteURL."downloads/sub4a.pdf",19,2,1,18,0,true),
   new MenuItem("SUB4b",$siteURL."sub4b.php",20,2,2,18,0,true),

   //Fifth Menu
   new MenuItem("TOP5",$siteURL."top5.php",21,1,5,0,0,true),

   //Sixth Menu
   new MenuItem("TOP6",$siteURL."top6.php",22,1,6,0,0,false),

   //Seventh Menu
   new MenuItem("TOP7",$siteURL."top7.php",23,1,7,0,0,false),

   //Eighth Menu
   new MenuItem("TOP8","http://www.externalsite.org/",24,1,8,0,1,true),

   );


Then you can access values in a more readable way. E.g.

foreach ($menu as $menuItem) {
  if (($menuItem-&gt;getLevel() === 1) &amp;&amp; ($menuItem-&gt;getDisplay() === true)) {
    ...
  }
}