I'm very new to PHP/Programming, so you can understand my frustration. Don't get me wrong I'm loving it.
My objective is to create an unordered list in PHP and display it in html.
I was able to successfully create the unordered list, and it shows up correctly.
My issue is when I try to display it to an HTML file using the fopen(); & fwrite();.
The error i'm getting is that it only display the last three values in my array when I switch over to my .html file. My code is below, any advice is appreciated.
$colors = array (
0 => array ("red", "black", "white"),
1 => array ("yellow", "blue", "green"),
2 => array ("orange", "grey", "pink"),
3 => array ("purple", "brown", "clear"),
);
foreach ($colors as $value) {
echo "<ul>";
$couleur = "<li>". implode ("</li><li>", $value) ."</li>";
echo $couleur;
echo "</ul>";
}
$y = fopen ("list.html", "w");
fwrite ($y, $couleur);
$couleuron eachforeachiteration. try using$couleur[] = ...$couleurevery iteration of your loop. Define$couleuraas an empty string before the loop; don't echo inside the loop, but use$couleur .= ...to build your string