2
Contributors
5
Replies
38
Views
1 Year
Discussion Span
Last Post by Stefan_1
0

You can use http://www.w3schools.com/tags/tag_details.asp

<?php
function makeList(array $Array) {
    $Output = '<details>';
    foreach($Array as $Key => $Value) {
        if(is_array($Value)) {
            $Output .= '<summary>'.$Key.'</summary>';
            $Output .= makeList($Value);
        } else {
            $Output .= '<div><a name="'.$Value.'" href="#">'.$Value.'</a></div>';
        }
    }
    $Output .= '</details>';
    return $Output;
}
?>

but is'n't supported on IE

Edited by AndrisP

0

better looks this

<?php
function makeList(array $Array, &$Output) {
    foreach($Array as $Key => $Value) {
        if(is_array($Value)) {
            $Output .= '<details>';
            $Output .= '<summary>'.$Key.'</summary>';
            $Output .= makeList($Value, $Output);
            $Output .= '</details>';
        } else {
            $Output .= '<div><a name="'.$Value.'" href="#">'.$Value.'</a></div>';
        }
    }
    return;
}
?>

add to style sheet padding

<!DOCTYPE html>
<head>
    <title>Categories</title>
    <style>
    details details { padding-left:30px; }
    </style>
</head>
<body>
<?php

makeList($categories, $Output);
echo $Output;

?>
</body>

is not mistake "details details { ... }" - root details witout padding but any contained <details> with "padding-left"

Edited by AndrisP

0

What browser (version) do you use? And what DOCTYPE is declared in your HTML? Tag "details" is new in HTML5. It can be unsupported if your DOCTYPE declared older than HTML5.
W3C maintains that it is working on Firefox 48, but in reality I can see that it works only on the Chromium-based browsers. I tested on FireFox 48 (Linux and Windows) both not properly supported "details" tag. On the Opera, Chromium and Google Chrome clickable "details" working properly.

Edited by AndrisP

0

Oh im using Edge and Mozilla BTW my default browser is Chrome but on chrome i got a vierd error when i want to connect on localhost its sayin me `Your connection is not private

Attackers might be trying to steal your information from localhost (for example, passwords, messages, or credit cards). NET::ERR_CERT_AUTHORITY_INVALID`

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.