Skip to content
Advertisement

Putting php arrays into html tags

I am trying to make a table that has different colors for each of its columns. There will be four columns.

JavaScript

I created an array called colors that has the strings of the colors I want, but I don’t know how to put that into the tag. I tried typing it in there, but since it is a string, it takes it as text instead of as code. Where it says “background-color:white;”, I’d like it to call the values from the array instead. Thanks.

Advertisement

Answer

You can array_pop for this provided you have exactly 4 columns. You also can’t apply background colours to <tr> like that, you need to apply them to the <td>

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement