将Html表显示为嵌套数组

时间:2016-02-25 02:26:44

标签: php html arrays multidimensional-array

我有一个html表,如下图所示..

enter image description here

我希望这个html表显示为嵌套数组,如下所示..

  Array
 (
   [Ron] => Array
    (
        [subject1] => Array
            (
                [test1] => 47
                [test2] => 86
                [total] => 133
                [percentage] => 88.67
                [status] => Pass
            )
        [pass_count] => 8
        [fail_count] => 0
        [gross_total] => 963
        [gross_percentage] => 80.25

        [...]

        [subject8] => Array
            (
                [test1] => 48
                [test2] => 86
                [total] => 134
                [percentage] => 89.33
                [status] => Pass
            )

        [pass_count] => 8
        [fail_count] => 0
        [gross_total] => 900
        [gross_percentage] => 75.50
    )

   [John] => Array
    (
        [subject1] => Array
            (
                [test1] => 39
                [test2] => 72
                [total] => 111
                [percentage] => 74
                [status] => Pass
            )
        [pass_count] => 8
        [fail_count] => 0
        [gross_total] => 963
        [gross_percentage] => 80.25

        [...]                

        [subject8] => Array
            (
                [test1] => 39
                [test2] => 75
                [total] => 114
                [percentage] => 76
                [status] => Pass
            )

        [pass_count] => 8
        [fail_count] => 0
        [gross_total] => 846
        [gross_percentage] => 70.5
    )

  )

我正在使用PHP来解析html表中的内容。我很困惑如何将表中的值显示或存储为嵌套数组

这是我要解析的html

           <div id="list">

            <table>
            <tbody><tr>
            <th>check1</th>
            <td class="name">Title1</td>
            <td class="description">para1</td>
            </tr>
            <tr>
            <td class="name">Title2</td>
            <td class="description">para2</td>
            </tr>
            <tr>
            <td class="name">Title1</td>
            <td class="description">para3</td>
            </tr>
            </tbody></table>


            <table>
            <tbody><tr>
            <th>check1</th>
            <td class="name">Title1</td>
            <td class="description">para1</td>
            </tr>
            <tr>
            <td class="name">Title2</td>
            <td class="description">para2</td>
            </tr>
            <tr>
            <td class="name">Title1</td>
            <td class="description">para3</td>
            </tr>
            </tbody></table>


            </div>

0 个答案:

没有答案