Add data between HTML tags to PHP array -


suppose have php variable bunch of data in tags. this:

$target_element = '<td colspan="3"> data header 1 </td>                     //colspan can not changed class or id.                            <td class="data_title"> title1_1 </td>                            <td class="data_item"> data1_1 </td>                              <td class="data_title"> title1_2 </td>                            <td class="data_item"> data1_2 </td>                              <td class="data_title"> title1_3 </td>                            <td class="data_item"> data1_3 </td>                               <td colspan="3"> data header 2 </td>                             <td class="data_title"> title2_1 </td>                            <td class="data_item"> data2_1 </td>                              <td class="data_title"> title2_2 </td>                            <td class="data_item"> data2_2 </td>'; 

what best way change above php array looks this:

array (     [0] => array         (             [0] => data header 1             [1] => array                 (                     [0] => title1_1                     [1] => data1_1                 )              [2] => array                 (                     [0] => title1_2                     [1] => data1_2                 )              [3] => array                 (                     [0] => title1_3                     [1] => data1_3                 )          )      [1] => array         (             [0] => data header 2             [1] => array                 (                     [0] => title2_1                     [1] => data2_1                 )              [2] => array                 (                     [0] => title2_2                     [1] => data2_2                 )          )  ) 

notice titles/data in each can vary.

thanks in advance help!


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -