I am trying to parse an html table into an multidimensional array and store the array into the database..
the html of my table looks as given below..
<div class="list">
<table cellspacing="0">
<tr class="tr-hover">
<th rowspan="15" scope="row">Network</th>
<td class="ttl"><a href="network-bands.php3">Technology</a></td>
<td class="nfo"><a href="#" class="link-network-detail">GSM / HSPA / LTE</a></td>
</tr>
<tr class="tr-toggle">
<td class="ttl"><a href="network-bands.php3">2G bands</a></td>
<td class="nfo">GSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2 (optional)</td>
</tr><tr class="tr-toggle">
<td class="ttl"><a href="network-bands.php3">3G bands</a></td>
<td class="nfo">HSDPA 850 / 900 / 1900 / 2100 </td>
</tr>
<tr class="tr-toggle">
<td class="ttl"><a href="network-bands.php3">4G bands</a></td>
<td class="nfo"> LTE</td>
</tr>
<tr class="tr-toggle">
<td class="ttl"><a href="glossary.php3?term=3g">Speed</a></td>
<td class="nfo">HSPA 42.2/5.76 Mbps, LTE Cat9 450/50 Mbps</td>
</tr>
<tr class="tr-toggle">
<td class="ttl"><a href="glossary.php3?term=gprs">GPRS</a></td>
<td class="nfo">Yes</td>
</tr>
<tr class="tr-toggle">
<td class="ttl"><a href="glossary.php3?term=edge">EDGE</a></td>
<td class="nfo">Yes</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<th rowspan="2" scope="row">Launch</th>
<td class="ttl"><a href=# onClick="helpW('h_year.htm');">Announced</a></td>
<td class="nfo">2016, February</td>
</tr>
<tr>
<td class="ttl"><a href=# onClick="helpW('h_status.htm');">Status</a></td>
<td class="nfo">Coming soon. 2016, March 11</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<th rowspan="6" scope="row">Body</th>
<td class="ttl"><a href=# onClick="helpW('h_dimens.htm');">Dimensions</a></td>
<td class="nfo">142.4 x 69.6 x 7.9 mm (5.61 x 2.74 x 0.31 in)</td>
</tr><tr>
<td class="ttl"><a href=# onClick="helpW('h_weight.htm');">Weight</a></td>
<td class="nfo">152 g (5.36 oz)</td>
</tr>
<tr>
<td class="ttl"><a href="glossary.php3?term=build">Build</a></td>
<td class="nfo">Corning Gorilla Glass back panel (unspecified version)</td>
</tr>
<tr>
<td class="ttl"><a href="glossary.php3?term=sim">SIM</a></td>
<td class="nfo">Single SIM (Nano-SIM) or Dual SIM (Nano-SIM, dual stand-by)</td>
</tr>
<tr><td class="ttl"> </td><td class="nfo">- Samsung Pay (Visa, MasterCard certified)<br />
- IP68 certified - dust proof and water resistant over 1.5 meter and 30 minutes</td></tr>
</table>
</div>
from this i want to create an array like
array (
[Network] =>
array (
['technology'] => 'GSM / HSPA / LTE',
['2G bands'] => 'GSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2 (optional)'
...
...
...
so on
),
['Launch'] =>
array (
['Announced'] => '2016, February',
....
...
so on
),
...
..
...
so on
)
what i have tried till now is..
used curl to get the html and then used dom as given below
foreach ( $e->find ( 'table' ) as $e1 ) {
$varinfo[] = $e1->innertext;
}
print_r($varinfo);
and i got
Array ( [0] => Network Technology GSM / HSPA / LTE 2G bands GSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2 (optional) 3G bands HSDPA 850 / 900 / 1900 / 2100 4G bands LTE Speed HSPA 42.2/5.76 Mbps, LTE Cat9 450/50 Mbps GPRS Yes EDGE Yes [1] => Launch Announced 2016, February Status Coming soon. 2016, March 11
so can someone help me out with getting the multidimensional array..i kind of stuck in this part for almost a long time now..
thank you