first try of making menu.inc recursive
authorSvenne Krap <svenne@krap.dk>
Thu, 28 Jun 2012 21:09:21 +0000 (23:09 +0200)
committerSvenne Krap <svenne@krap.dk>
Thu, 28 Jun 2012 21:09:21 +0000 (23:09 +0200)
inc/menu.inc

index 04450181dddff69d981e1f1e006da400078e86c7..b4ee78b9dd66ac75094ad0aaac01aa4e4da25b91 100644 (file)
@@ -1,8 +1,31 @@
 <?php
 class menu {
-    var $data = array();
+    private $data = array();
 
-    function draw() {
+    function __construct($data = null) {
+        if (!is_null($data)) $this->data = $data;
+    }
+
+    function draw($data) {
+        echo "<ul>";
+        foreach($data as $key=>$val) {
+            echo "<li>";
+            if (is_array($val)) {
+                echo $key;
+                echo " -> ";
+                $this->draw($val); 
+            } else {
+                echo $key;
+                echo " -> ";
+                echo $val; 
+            }
+            echo "</li>";
+        }
+        echo "<ul>";
+    }
+
+    function run() {
+        $this->draw($this->data);
     }
 }
 ?>