I have the following html string snippett from a wikipedia page...
<table class="wikitable">
<tbody>
<tr>
<td>mod_access</td>
<td>Versions older than 2.1</td>
<td>Included by Default</td>
</tr>
<tr>
<td>mod_actions</td>
<td>Versions 1.1 and later</td>
<td>Included by Default</td>
</tr>
<tr>
<td>mod_alias</td>
<td>Versions 1.1 and later</td>
<td>Included by Default</td>
</tr>
</tr>
</tbody>
I have the following php code....
ini_set('display_errors','On');
$url="https://en.wikipedia.org/wiki/List_of_Apache_modules";
$dom=new DomDocument();
$dom->preserveWhiteSpace=false;
$dom->loadHtmlFile($url);
$xpath=new DomXpath($dom);
$elements=$xpath->query('//*[@id="mw-content-text"]/div/table/tbody/tr/td');
foreach($elements as $i=>$row){
$tds=$xpath->query('td',$row);
foreach($tds as $td){
echo "Td($i):", $td->nodeValue,"\n";
}
}
What i'd like in return is a numerical array with each index a table row filled with the td values.
Not quite sure what to do next.
tr) instead of the individual cells? Your initial$elementscontains all of the cells, not all of the rows.