Re: preg_match_all & if

From: Date: Thu, 24 Apr 2003 20:18:40 +0000
Subject: Re: preg_match_all & if
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145195@lists.php.net to get a copy of this message
try... if( preg_match_all(....) ) { echo "stuff"; } elseif( preg_match_all(....) ) { echo "stuff"; } notice the parentheses.... -- Chris Edwards Web Application Developer Outer Banks Internet, Inc. 252-441-6698 chris.edwards@obinet.com http://www.OuterBanksInternet.com ----- Original Message ----- From: "Jay Fitzgerald" <jayfitz@bayou.com> To: <php-general@lists.php.net> Sent: Thursday, April 24, 2003 4:07 PM Subject: [PHP] preg_match_all & if > I have a preg_match_all statement that is currently working when I search > through txt files that clients upload... > > // code > preg_match_all("|TEXT TO SEARCH FOR|U",$read,$result); > // end_code > > My question is: is there a way or can you place IF statements inside of > preg-match statements? > > Example: > > IF preg_match_all("<tr align=\"left\"> \n > <td colspan=\"3\"><font face=\"Arial, Verdana, > Helvetica, sans-serif\" size=\"2\" color='red'><a href=\"#\" > onMouseOver=\"status='Click to read Severe Weather Alert bulletin'; return > true;\" onMouseOut=\"status=''\" > onClick=\"zone_bull=window.open('cgi-bin/get_ww.cgi?zid=LAZ028', > 'zone_bull', 'scrollbars,resizable,width=500, height=400'); > zone_bull.focus(); return false;\"><font color=#ff0000>Severe Weather > Alert</font></a></font>&nbsp;</td>\n > <td colspan=\"2\"><font face=\"Arial, Verdana, > Helvetica, sans-serif\" size=\"2\" color='red'><a href=\"#\" > onMouseOver=\"status='Click to read National Weather Service zone > forecasts'; return true;\" onMouseOut=\"status=''\" > onClick=\"zone_bull=window.open('cgi-bin/get_zone.cgi?zid=LAZ028&format=4', > 'zone_bull', 'scrollbars,resizable,width=500, height=400'); > zone_bull.focus(); return false;\"><font color=#0000FF>Zone > Forecast</font></a></font>&nbsp;</td>\n > </tr>\n|U", $read, $result); > { > echo "this has a red link"; > } > > ELSEIF preg_match_all("<tr align=\"left\"> > <td colspan=\"3\"><font face=\"Arial, Verdana, > Helvetica, sans-serif\" size=\"2\" color='red'><font face=arial > color=#999999>Severe Weather Alerts</font></font>&nbsp;</td> > <td colspan=\"2\"><font face=\"Arial, Verdana, > Helvetica, sans-serif\" size=\"2\" color='red'><a href=\"#\" > onMouseOver=\"status='Click to read National Weather Service zone > forecasts'; return true;\" onMouseOut=\"status=''\" > onClick=\"zone_bull=window.open('cgi-bin/get_zone.cgi?zid=LAZ028&format=4', > 'zone_bull', 'scrollbars,resizable,width=500, height=400'); > zone_bull.focus(); return false;\"><font color=#0000FF>Zone > Forecast</font></a></font>&nbsp;</td>\n > </tr>\n|U", $read, $result); > { > echo "this does not have a link"; > } > > why isnt this working for me? > > > > Jay Fitzgerald, Design Director - CPW-A, CPWDS-A, CPWDV-A, CECM-A, CWCSB-A > Bayou Internet - http://www.bayou.com > Toll Free: 888.30.BAYOU (22968) > Vox: 318.338.2034 / Fax: 318.338.2506 > E-Mail: jayfitz@bayou.com > ICQ: 38823829 / AIM: bayoujf / MSN: bayoujf / Yahoo: bayoujf > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#145195) next »