fetching data from html tables using php

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
jito
Forum Commoner
Posts: 85
Joined: Sat Mar 25, 2006 4:32 am
Location: india

fetching data from html tables using php

Post by jito »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,
can anybody help me to fetch data from a html table to a text file using php.
I have tried that code:

Code: Select all

while ( ! feof( $fpr ) ) 
{
   $str .=fgets( $fpr);

}

$do = preg_match_all("/<td>(.*)<\/td>/", $str, $matches,PREG_PATTERN_ORDER);


foreach($matches as $key=>$val)
{
	
	foreach($val as $v1)
	{
		echo ($v1)."<br>";
		
	}
	
}
but i don't have the desired output. Anything i should modify in regex?


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What's the input loop like? What's the output you'd like to see?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

change .* to " .*? " ;)
Post Reply