I have meeting a problem with "preg_match_all" when I read some message from a text file, such as:
data.txt
<table>
<tr>
<td>abc</td>
</tr>
<tr>
<td>def</td>
</tr>
</table>
I want to know how many rows in the table and want to get each rows of it. so I know if I use
test.php
$fp = fopen("data.txt","r");
$str = fread($fp,filesize($fp));
fclose($fp);
I know use:
$result = preg_match_all('/<td>.*.<\/td>/',$str,$rows);
can match all cols,
but because the "<tr>" and "</tr>" not in a same line, so I can't match the "<tr>", who can tell me how to do it?