| @@ 92-112 (lines=21) @@ | ||
| 89 | $html = str_get_html($data); |
|
| 90 | if ($html === false) return array(); |
|
| 91 | $tabledata=array(); |
|
| 92 | foreach($html->find('tr') as $element) |
|
| 93 | { |
|
| 94 | $td = array(); |
|
| 95 | foreach( $element->find('th') as $row) |
|
| 96 | { |
|
| 97 | $td [] = trim($row->plaintext); |
|
| 98 | } |
|
| 99 | $td=array_filter($td); |
|
| 100 | $tabledata[] = $td; |
|
| 101 | ||
| 102 | $td = array(); |
|
| 103 | $tdi = array(); |
|
| 104 | foreach( $element->find('td') as $row) |
|
| 105 | { |
|
| 106 | $td [] = trim($row->plaintext); |
|
| 107 | $tdi [] = trim($row->innertext); |
|
| 108 | } |
|
| 109 | $td=array_filter($td); |
|
| 110 | $tdi=array_filter($tdi); |
|
| 111 | $tabledata[]=array_merge($td,$tdi); |
|
| 112 | } |
|
| 113 | $html->clear(); |
|
| 114 | unset($html); |
|
| 115 | return(array_filter($tabledata)); |
|
| @@ 940-961 (lines=22) @@ | ||
| 937 | private static function table2array($data) { |
|
| 938 | $html = str_get_html($data); |
|
| 939 | $tabledata=array(); |
|
| 940 | foreach($html->find('tr') as $element) |
|
| 941 | { |
|
| 942 | $td = array(); |
|
| 943 | foreach( $element->find('th') as $row) |
|
| 944 | { |
|
| 945 | $td [] = trim($row->plaintext); |
|
| 946 | } |
|
| 947 | $td=array_filter($td); |
|
| 948 | $tabledata[] = $td; |
|
| 949 | ||
| 950 | $td = array(); |
|
| 951 | $tdi = array(); |
|
| 952 | foreach( $element->find('td') as $row) |
|
| 953 | { |
|
| 954 | $td [] = trim($row->plaintext); |
|
| 955 | $tdi [] = trim($row->innertext); |
|
| 956 | } |
|
| 957 | $td=array_filter($td); |
|
| 958 | $tdi=array_filter($tdi); |
|
| 959 | // $tabledata[]=array_merge($td,$tdi); |
|
| 960 | $tabledata[]=$td; |
|
| 961 | } |
|
| 962 | return(array_filter($tabledata)); |
|
| 963 | } |
|
| 964 | ||