0

I have an html table as shown in the image below..

enter image description here

I want this html table to be displayed as an nested array as shown below..

  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
    )

  )

I'm using PHP to parse the contents from the html table. I'm confused how to display or store the values from the table as nested array

here is the html i want to parse

           <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>
Susan Williams
  • 317
  • 3
  • 18

0 Answers0