Create a nav from an array in PHP? [closed]

-5

My teacher asks me to build an array from PHP. I really do not know how to do it and I wanted to ask for help. If someone is so kind to explain it. Thank you very much

    
asked by Nicolas Otondo 09.11.2018 в 15:53
source

1 answer

0

A very simple example is that in your array you have several data like, title of the link and URL of the link.

PHP AND HTML :

<?php
    $arrayUrls = [
        [
            'title' => 'Facebook',
            'url' => 'www.facebook.com'
        ],
        [
            'title' => 'Google',
            'url' => 'www.google.com'
        ]
    ];
?>

<nav>
    <ul>
        <?php
            foreach ($arrayUrls as $url)
            {
                ?>
                    <li><a href="<?php echo $url['url']; ?>"><?php echo $url['title']; ?></a></li>
                <?php
            }
        ?>
    </ul>
</nav>

It's a very simple example, I hope it serves as a reference!

    
answered by 09.11.2018 / 17:36
source