menu-uit-array

Gesponsorde koppelingen

PHP script bestanden

  1. menu-uit-array

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="Robert Deiman" />
    <meta http-equiv="charset" content="iso-8859-1" />
    <meta http-equiv="content-language" content="nl-en" />
    <meta name="title" content="mutidymensionaal menu" />
    <title>Multidymensionaal menu</title>
    <style>
    a:link.active{
        color:#00ccbb;    
        text-decoration:none;    
        }
    a:visited.active{
        color:#00ccbb;    
        text-decoration:none;    
        }
    a:hover.active{
        color:#00ccbb;    
        text-decoration:underline;    
        }
    a:active.active{
        color:#00ccbb;    
        text-decoration:none;    
        }
    a:link{
        color:#000000;    
        text-decoration:none;    
        }
    a:visited{
        color:#000000;    
        text-decoration:none;    
        }
    a:hover{
        color:#000000;    
        text-decoration:underline;    
        }
    a:active{
        color:#000000;    
        text-decoration:none;    
        }
        
/*    a:link {color: #FF0000}  
a:visited {color: #00FF00}
a:hover {color: #FF00FF}
a:active {color: #0000FF}
*/
    </style>
</head>
<body>
<?php

error_reporting(E_ALL);
ini_set('error_reporting',1);
/**
 * @author Robert Deiman
 * @copyright 2008
 * @param $array_items Array Contains a multidymensional array with the items for the menu
 */


function generate_menu($array_items)
    {

        if(!isset($return_string)){
            $return_string = '<ul>'."\n";
            }

        foreach($array_items AS $key => $value)
        {

               if(!is_array($value))
            {

                if($value == $_GET['pag'])
                {

                    $actief = ' class="active"';
                }

                else
                {
                    $actief = '';
                }

                   $return_string .= '<li><a href="?pag='.$value.'"'.$actief.'>'.$value.'</a></li>'."\n";
            }
  
               else
            {
                if($key == $_GET['pag'])
                {

                    $actief = ' class="active"';

                }

                else
                {
                    $actief = '';
                }

                
                //print_r($value);
                   $return_string .= '<li><a href="?pag='.$key.'"'.$actief.'>'.$key.'</a>'."\n";
                $return_string .= generate_menu($value);
                $return_string .= '</li>';
            }
           }

           $return_string.= '</ul>'."\n";
           return $return_string;
    }

      
$menu = array('home','nieuws'=>array('archief','laatste','recent'=>array('vandaag','gisteren')),'contact');


echo generate_menu($menu);
?>

</body>
</html>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.