Thank You very much! It Really works the way I want it to. But i still have a slight problem. The script cant read the data if it is on several rows. For example: <table> <font color=black> <tr>text</tr> </font> </table>
Is there a way to fix this problem? Thank You! "Chris Hayes" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > At 17:21 8-2-2003, you wrote: > >Hi > >I have to alter this code: > ><?php > >$fp = fopen ('http://www.whatever.ee/', 'r'); > > > >for ($src = ''; !feof ($fp); $src .= fgets ($fp, 1024)); > > > >fclose ($fp); > > > >if (preg_match ('/\<font color=black\>([^<]*)\<\/font>/i', $src, $matches)) > > echo 'Match: <b>'.$matches[1].'</b>'; > >else > > echo 'No match !'; > >?> > > > >It extracts the data (words) from www.whatever.com between <font=black> and > ></font>. > >It works well if the source looks something like this: > ><font=black>text</font> (it echos "text") > >but i am having some serious problems when the source looks like > >this<table><font=black><tr>text</tr></font></table>. It wont do anything if > >it is supposed to echo html. but i need html! > >Could somebody help me change the script so that it can extract html as > >well? > >If you can, mail me at [EMAIL PROTECTED] or just reply here.... > >Thank You! > > > anyway. this did what you asked for. > > <?PHP > $src='<table><font color=black><tr>text</tr></font></table>.'; > $pattern='/\<font color=black\>(.*)\<\/font>/i'; > > if (preg_match ($pattern, $src, $matches)) > echo 'Match: <b>'.htmlspecialchars($matches[0]).'</b>'; > else > echo 'No match !'; > > ?> > > note that i show the output with htmlspecialchars() so you can actually see > the tag while testing > also note that i replaced your [^<]* with .* > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php