nobtiba Posted August 13, 2013 Share Posted August 13, 2013 Hi Bros, I got head-ache trying to solve this problem. I have a structure like this: <tr><td width="10%" bgcolor="#FFFFFF"><font class="bodytext9">17-Aug-2013</font></td><td width="4%" bgcolor="#FFFFFF" align=center><font class="bodytext9">Sat</font></td><td width="4%" bgcolor="#FFFFFF" align="center"><font class="bodytext9">5 PM</font></td><td width="15%" bgcolor="#FFFFFF" align="center"><a class="black_9" href="teams.asp?teamno=766&leagueNo=115">XYZ Club FC</a></td><td width="5%" bgcolor="#FFFFFF" align="center"><font class="bodytext9"><img src="img/colors/white.gif"></font></td><td width="5%" bgcolor="#FFFFFF" align="center"></td><td width="5%" bgcolor="#FFFFFF" align="center"><font class="bodytext9">vs</font></td><td width="5%" bgcolor="#FFFFFF" align="center"></td><td width="5%" bgcolor="#FFFFFF" align="center"><font class="bodytext9"><img src="img/colors/orange.gif"></font></td><td width="15%" bgcolor="#FFFFFF" align="center"><a class="black_9" href="teams.asp?teamno=632&leagueNo=115">ABC Football Club</a></td><td width="15%" bgcolor="#FFFFFF" align="center"><a href="pitches.asp?id=151" class=list><u>APSM Pitch </u></a></td><td width="4%" bgcolor="#FFFFFF" align="center"><a target="_new" href="matchpreview_frame.asp?matchno=20877"><img src="img/matchpreview_symbol.gif" border="0"></a></td></tr> this format will repeat many times with different text contain, sometime, some text contain is similar. I need to extract ONLY the FIRST group of this format, where it contain "ABC Football Club" the FIRST TIME (because it could appear many times later also). How do I do that and extract the text on each line ? Quote Link to comment https://forums.phpfreaks.com/topic/281115-get-text-between-repeating-tags/ Share on other sites More sharing options...
fastsol Posted August 13, 2013 Share Posted August 13, 2013 How are you getting the data for the rows? From a database? You may be able to use the GROUP BY clause. We will need some more precise info from you to help further. Also you really need to use css to format the table rather than the horrible repeated inline styling you have now. Quote Link to comment https://forums.phpfreaks.com/topic/281115-get-text-between-repeating-tags/#findComment-1444755 Share on other sites More sharing options...
.josh Posted August 13, 2013 Share Posted August 13, 2013 well.. you didn't really provide details about how you wanted the text to be returned.. but here is one way to do it: preg_match('~<tr>.*?ABC Football Club.*?</tr>~is',$content,$match); if (isset($match[0])) $text = strip_tags($match[0]); $content is the text you are trying to extract the info from, and $text will then contain something like this: 17-Aug-2013 Sat 5 PM XYZ Club FC vs ABC Football Club APSM Pitch Basically the code grabs the first tr block that has that "ABC Football Club" string within it, and then strips all the html tags from it, leaving the text and linebreaks. From there, it kinda depends on what you're going for, but I assume you don't need help as far as string manipulation.. Quote Link to comment https://forums.phpfreaks.com/topic/281115-get-text-between-repeating-tags/#findComment-1444872 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.