Sadece html tablodan veri php preg_match_all alışmak

0 Cevap php

Ben böyle bir html tablo var:

<table ... >

  <tbody ... >

       <tr ... > 
             <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
       </tr>
        <tr ... > 
             <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
                <td ...>
                  string...
              </td>
                <td ...>
             </td>
                <td ...>
                  string...
              </td>
       </tr>
       ..............

  </tbody>


</table>

This is a data table and I need to get all data from this. The table will have many rows (<tr></tr>) . each row will have a fixed columns (<td></td>)(currently is 5 ). remember each table,tr,td tag maybe formatted (where say "...")

Ve ben herkes bana bu gibi verileri almak için preg_match_all fonksiyonu için bir regex yazmak için yardımcı olur umarım:

array(
   0 => array(
       0=> 'some data0',
       1=> 'some data1',
       2=> 'some data2',
       3=> 'some data3',
       4=> 'some data4',
   )
   1 => array(
       0=> 'some data0',
       1=> 'some data1',
       2=> 'some data2',
       3=> 'some data3',
       4=> 'some data4',
   )
   2 => array(
       0=> 'some data0',
       1=> 'some data1',
       2=> 'some data2',
       3=> 'some data3',
       4=> 'some data4',
   )
..........
)

Şimdi test için örnek hopfully bana yardımcı olabilir!

<table border="1" >
  <tbody style="" >

       <tr style="" > 
             <td style="color:blue;">
                  data0
              </td>
                <td style="font-size:15px;">
                 data1
              </td>
                <td style="font-size:15px;">
                  data2
              </td>
                <td style="color:blue;">
                  data3
              </td>
                <td style="color:blue;">
                  data4
              </td>
       </tr>
       <tr style="" > 
             <td style="color:blue;">
                  data00
              </td>
                <td style="font-size:15px;">
                 data11
              </td>
                <td style="font-size:15px;">
                  data22
              </td>
                <td style="color:blue;">
                  data33
              </td>
                <td style="color:blue;">
                  data44
              </td>
       </tr>
       <tr style="color:black" > 
             <td style="color:blue;">
                  data000
              </td>
                <td style="font-size:15px;">
                 data111
              </td>
                <td style="font-size:15px;">
                  data222
              </td>
                <td style="color:blue;">
                  data333
              </td>
                <td style="color:blue;">
                  data444
              </td>
       </tr>

  </tbody>


</table>

0 Cevap