john_bboy7 Posted April 21, 2009 Share Posted April 21, 2009 I want to preg_match from the last result i got from preg_match. is it possible? For example: preg_match_all($pattern, $search , $matches1); foreach($matches1[0] as $val1){ echo $val1 . "<br />\n"; } Now i want to preg_match_all from the result i got in $val1 (From all matches) so what will i put in place of $search this time in below line: preg_match_all($pattern, $search , $matches1); No $val1 doesnt works i tried. Link to comment https://forums.phpfreaks.com/topic/155042-how-to-preg_match-from-the-last-preg_match-result/ Share on other sites More sharing options...
john_bboy7 Posted April 21, 2009 Author Share Posted April 21, 2009 Have i posted in wrong section? is it goes to regex section? Link to comment https://forums.phpfreaks.com/topic/155042-how-to-preg_match-from-the-last-preg_match-result/#findComment-815507 Share on other sites More sharing options...
9three Posted April 21, 2009 Share Posted April 21, 2009 Did you put the preg match all within the foreach loop? Link to comment https://forums.phpfreaks.com/topic/155042-how-to-preg_match-from-the-last-preg_match-result/#findComment-815521 Share on other sites More sharing options...
john_bboy7 Posted April 21, 2009 Author Share Posted April 21, 2009 Did you put the preg match all within the foreach loop? Nope...infact i dont want it to be there.. the main view of my code is that i am extracting a piece of HTML first.. which will remove all the irrelevent stuff. then i want to preg match from that piece of html. And no i can not do it in first match as first match also contains the second match which i dont want it to b in.. Link to comment https://forums.phpfreaks.com/topic/155042-how-to-preg_match-from-the-last-preg_match-result/#findComment-815524 Share on other sites More sharing options...
The Little Guy Posted April 21, 2009 Share Posted April 21, 2009 preg_match_all($pattern, $search , $matches1); foreach($matches1[0] as $val1){ preg_match($anotherPattern, $val1, $matches2); echo '<pre>';print_r($matches2);echo '</pre>'; } Link to comment https://forums.phpfreaks.com/topic/155042-how-to-preg_match-from-the-last-preg_match-result/#findComment-815801 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.