Page 1 of 1

preg_match help please

Posted: Mon Feb 06, 2006 4:29 pm
by jasondavis

Code: Select all

<td id="ProfileGeneral" width="175" bgcolor="#d5e8fb" style="WORD-WRAP: break-word"></style>hoho"
<br>
Male<br>22 years old<br>Lake Helen, FL<br>
<br>
Last Login: comming soon<br>
</td></tr><tr><td colspan="4">
<a href="http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewPicture&friendID=10021628">
view more pics (10)</a>
can someone help me I need to get the proper preg_match to extract the Male or Female of pages that will be just like this code

I have this for other items from the same page this code is on

Code: Select all

preg_match("/<span class=\"nametext\">(.*)<\/span>/", $html, $msname);
				preg_match("/<td class=\"text\" width=\"193\" bgcolor=\"#ffffff\" height=\"75\" align=\"left\">\"(.*)\"<br>/", $html, 	$msdata);
				preg_match("/has <span class=\"redbtext\">(\d+)<\/span> friends/", $html, $msfc);
				preg_match("/(\d+) years old/", $html, $msyo);

Posted: Mon Feb 06, 2006 4:35 pm
by feyd

Code: Select all

preg_match('#<\s*br(?:\s*/)?>\s*((?:fe)?male)\s*<\s*br(?:\s*/)?>#is',$html,$sex);

Posted: Mon Feb 06, 2006 4:38 pm
by jasondavis
you're awsome thanks

Posted: Mon Feb 06, 2006 4:58 pm
by jasondavis
one small problem it works but I guess some pages must be different because its picking up other data for some users, any solution to this?
Image

looking at the profile page of that first entry in the pic above the source area looks like this

Code: Select all

<td class="text" width="193" bgcolor="#ffffff" height="75" align="left">"The Kaz"<br>
			    <br>
			    Male
			    <br>
			    26 years old