We should have a 3 on 3 sign.

array( 'text' => 'Текст красного цвета', 'cells' => '1,2,4,5' ), array( 'text' => 'Текст зеленого цвета', 'cells' => '8,9' ), 

There is a function that takes type values. The numbers in the array indicate those cells that should be whole. It is necessary to generate a table using these parameters. What is the best way to make the page look like this?

alt text

  • one
    @noskovgleb, According to the rules of the forum, questions should not be limited to solving or completing student assignments. Please clarify what you have done yourself and what did not work out. - Artem
  • I thought to do it through the <table> and <td> <tr> tags, but I don’t know how to take into account that with colspan and rowspan, some parts of the table will pop out, and not just merge. - Kokoko

1 answer 1

You should first understand how colspan and rowspan work, unless, of course, you know how they work. Then make a pre-calculation for the entire table. Actually nobody will be smart in doing this in the evening, so I advise you tomorrow morning, with a fresh head, stand up, eat, draw a more pleasant picture and start thinking about the conditions and blocks to add colspan and rowspan, ticking with a pen or pencil marks on a white A4 sheet (this is a must! Verified).

Because 3x3 grid, then there are different ways to create a table. The easiest way is to do a search of all positions and put it somewhere. And then just watch the values. But it is a chore.

Dare! But if the brain suddenly gets stuck at some point, then write, we will help :-) But we will only help, but not write.

  • So I also thought of doing this, going through all the positions, but it seems to me to be completely wrong. Maybe there is some other way, maybe using javascript ...? - Kokoko
  • @ Kokoko is not the point, in what language to write. The algorithm itself is important. Here it is. - lampa