Quote:
Originally Posted by V@no
um....it captures only one <td> per table...
|
Nope, it captures them all. Whether you are processing them correctly is a different thing. (I've removed the HTML formatting and just put a print_r to display the complete array so that you can see what info you *actually* capture, rather than what you're displaying).
Code:
<?php
$text = '
<table>
<tr>
<td>tb1-tr1-td1</td>
<td>tb1-tr1-td2</td>
<td>
<span>
tb1-tr1-td3
<span>
</td>
<td>
tb1-tr1-td4
</td>
</tr>
<tr>
<td>tb1-tr2-td1</td>
<td><span>tb1-tr2-td2</span></td>
<td>
tb1-tr2-td3
</td>
</tr>
</table>
<table>
<tr>
<td>tb2-tr1-td1</td>
<td><span>tb2-tr1-td2</span></td>
<td>
tb2-tr1-td3
</td>
</tr>
</table>
';
$text = preg_replace('#\r\n|\n#', '', $text);
preg_match_all('#<td>(.+?)</td>#', $text, $result);
print_r($result);
?>
Edit: If you are spreading one lot of tabular data across multiple lines, you also need to remove newlines and such from the $text string for the regex to capture those. That's done by the preg_replace line I've added above.