<html lang="en"> <head> <title>Title goes here</title> <link rel="shortcut icon" href="favicon.ico" > </head> <body bgcolor="#ffffff" link="#a02222" vlink="#888888" alink="#cc3333"> <p>This is a stripped-down version of the PHP code which implements collapsible trees on <a href="http://math.arizona.edu/~kerl">my home page</a>. The source code is <a href="idxshort.html">here</a>. Enjoy! <?php # ================================================================ # John Kerl # kerl.john.r@gmail.com # 2007-05-16 # ================================================================ $usrv = $_GET['v']; $v = isset($usrv) ? $usrv : 0; if (is_string($v)) { if ($v == 'label1') $v = 0x01; else if ($v == 'label2') $v = 0x02; else if ($v == 'label3') $v = 0x04; } $n01 = $v ^ 0x01; $n02 = $v ^ 0x02; $n04 = $v ^ 0x04; echo "<ul>"; echo "<li> <a href=\"idxshort.php?v=$n01\">Text here</a>"; if ($v & 0x01) { ?> <!-- Plain HTML here --> <ul> <li> Content here <li> Content here <li> Content here </ul> <?php } echo "<li> <a href=\"idxshort.php?v=$n02\">Text here</a>"; if ($v & 0x02) { ?> <ul> <li> Content here <li> Content here </ul> <?php } echo "<li> <a href=\"idxshort.php?v=$n04\">Text here</a>"; if ($v & 0x04) { ?> <ul> <li> Content here <li> Content here <li> Content here <li> Content here </ul> <?php } echo "</ul>"; ?> <p> <a href="idxshort.php?v=255">Expand all</a> | <a href="idxshort.php?v=0">collapse all</a> </body> </html>