note 92083 rejected from function.preg-match-all by danbrown

From: Date: Wed, 08 Jul 2009 15:27:04 +0000
Subject: note 92083 rejected from function.preg-match-all by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158070@lists.php.net to get a copy of this message
Note Submitter: Eng_A_Moktar at yahoo dot com ---- Hi, I wanna make a general pattern for example i have this string , i wanna capture the titles and links of this topic : <?php $str="<td valign='top'> <center> <a href='redirect-5321'> Zito, Romo combo zero <br><br> <img src='images/img280745.png' border='0' width='190' height='190'></a> </center> <br> </td></tr><tr> <td valign='top'> <center> <a href='redirect-5322'> NBA salary cap set at $57.7 million <br><br> <img src='images/img280746.png' border='0' width='190' height='190'></a> </center> <br> </td></tr><tr>"; // define start and end $title_start = ">"; $title_end = "<br><br>"; $link_start = "<a href='"; $link_end = "'"; $code = preg_match_all("/{$title_start}(.*?){$title_end}/", $str, $result1); $code = preg_match_all("/{$link_start}(.*?){$link_end}/", $str, $result2, PREG_PATTERN_ORDER); echo $result1[1][0]; echo "<br />"; echo $result2[1][0]; echo "<br />"; ?> in this example, title pattern doesn't work, because there are spaces and lines, what i wanna say, how can i make my pattern wider and flexible, even works with tags or words ? thanks.

« previous php.notes (#158070) next »