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
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
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!