An html table stored in a variable as a lot of rows like this, and I want to remove only some of them, depending on what is in the spot that says "Some Words Here":
<TR VALIGN="middle" BGCOLOR="#CCEEFF">
<TD NOWRAP>
<FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#000000">Some Words Here</FONT></TD><TD>
<FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#000000">Blah Blah </FONT></TD><TD NOWRAP align=center>
<FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#CCFFCC">1/1/2005<BR>1:00:01 AM</FONT></TD><TD ALIGN="right" NOWRAP>
<FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#000000">1,234</FONT></TD><td width=48 valign=middle><FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#CC0000"><b> <NOBR>0.00</NOBR></b></FONT></td><TD ALIGN="right" NOWRAP> <b>
<FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#000000"><FONT FACE="Arial,Helvetica,sans-serif" SIZE="2" COLOR="#CC0000">0.00%</b></TD>
</TR>
Let's say one of the rows has "This is nice" instead of "Some words here." I tried this regex, but it was ignored:
$table = preg_replace('/<TR VALIGN=\"middle\" BGCOLOR=\"#CCEEFF\"><TD NOWRAP>
<FONT FACE=\"Arial\,Helvetica\,sans-serif\" SIZE=\"2\" COLOR=\"#000000\">This is nice(.*?)
<\/TR>/is', '', $table);
How can I make this work to delete the row that has "This is nice"?
Also, if I have several specific rows to delete (identified by different key words), would it make sense to explode all the rows into an array and then delete the array elements that contain the given keywords? If so, how?
ASKER
For some reason I still can't get it to work. Please copy and paste the exact variable value and the exact regex that you're using. Then I'll copy and paste exactly from it, to test.
Also, I'd appreciate a comment on the second part of the question: If I am going to be inserting only certain rows into a database (after deleting certain rows identified by different key words), would it make sense to explode all the rows into an array and then delete the array elements that contain the given keywords? If so, how? Or would that just complicate matters; should I just use regex to remove the rows before exploding into an array? Thanks.