I have a page, and there are lines in the code like this:
<td width="85%" class="txt">THIS</td>
<td width="85%" class="txt">THAT</td>
<td width="85%" class="txt">THERE</td>
<td width="85%" class="txt">ALWAYS</td>
<td width="85%" class="txt">NEVER</td>
How can i put the words 'THIS', 'THAT' , 'THERE', 'ALWAYS', 'NEVER' (they are always changing) into an array? I've tried with the command eregi, but that seems to be pretty hard to do...
Pls, can ya help me?
Thx a lot!!
<?php
$dummy = '<td width="85%" class="txt">THIS</td>
<td width="85%" class="txt">THAT</td>
<td width="85%" class="txt">THERE</td>
<td width="85%" class="txt">ALWAYS</td>
<td width="85%" class="txt">NEVER</td>';
$pattern = '#<td width="85%" class="txt">(.+?)</td>#';
echo '<pre>';
if (preg_match_all($pattern,$dummy,$matches))
print_r($matches);
echo '</pre>';
?>
Thanks a lot!!
I will give this a try...
Ok, this works fine,
but sometimes the code is like this, so he doesn't add this into the string...
<td width="85%" class="txt">THIS</td>
<td width="85%" class="txt">TH
AT</td>
<td width="85%" class="txt">THERE</td>
<td width="85%" class="txt">ALWAYS</td>
<td width="85%" class="txt">NEVER</td>
Replace
$pattern = '#<td width="85%" class="txt">(.+?)</td>#';
with
$pattern = '#<td width="85%" class="txt">(.+?)</td>#s';
and it works for multiple lines, too...