从Php Array创建交叉html表

时间:2016-12-16 13:54:32

标签: php html

Array
(
[Group1] => Array
    (
        [someDay1] => Array
            (
                [empty] => 5
                [full] => 8
            )

        [someDay2] => Array
            (
                [empty] => 2
                [full] => 6
            )

    )

[Group2] => Array
    (
        [someDay1] => Array
            (
                [empty] => 2
                [full] => 6
            )

        [someDay2] => Array
            (
                [empty] => 2
                [full] => 4
            )

    )

我想根据Groups和Dates创建交叉表,这是我想要的输出:

Table

是否可以使用此类数组创建这样的交叉表?我很困惑。

1 个答案:

答案 0 :(得分:0)

以下是您可以做的事情:



table, tr, td, th {
  border: 1px solid black
}

<table>
  <tr>
    <th colspan="2"></th>
    <th>Someday1</th>
    <th>Someday2</th>
  </tr>
  <tr>
    <td rowspan="2">Group1</td>
    <td>Empty</td>
    <td>5</td>
    <td>3</td>
  </tr>
  <tr>
    <td>Full</td>
    <td>8</td>
    <td>6</td>
  </tr>
  <tr>
    <td rowspan="2">Group2</td>
    <td>Empty</td>
    <td>2</td>
    <td>2</td>
  </tr>
  <tr>
    <td>Full</td>
    <td>6</td>
    <td>4</td>
  </tr>
</table>
&#13;
&#13;
&#13;

Here is a tutorial to help you