preg_match_all - how does it work?

From: Date: Sun, 17 Nov 2002 16:13:00 +0000
Subject: preg_match_all - how does it work?
Groups: php.general 
Request: Send a blank email to php-general+get-124797@lists.php.net to get a copy of this message
I have some experience in using regular expressions in Perl, and have been able to use preg_match in php, but am having a problem with preg_match_all. I'm trying to extract data from an HTML table. Here's my preg_match call that correctly grabs the 1st row of data in the table. It grabs 4 columns of data: preg_match("|<tr class=\"CART_TD_REG\".+?<td.+?>(.*?)<.+?<td.+?>(.*?)<.+?<td.+?>(.*?)<.*?<inp ut.*?>[&nbsp;]*(.*?)</td>.*?</tr>|", $res, $match); If I use preg_match_all on the same table: preg_match_all("|<tr class=\"CART_TD_REG\".+?<td.+?>(.*?)<.+?<td.+?>(.*?)<.+?<td.+?>(.*?)<.*?<inp ut.*?>[&nbsp;]*(.*?)</td>.*?</tr>|", $res, $match, PREG_PATTERN_ORDER); ...and try to print output, I get: $match[0] = Array $match[0][0] = Array[0] $match[1][0] = Array[0] $match[0][1] = Array[0] $match[1][1] = Array[0] Same result with PREG_SETORDER. What am I doing wrong? -- Randall Perry sysTame Xserve Web Hosting/Co-location Website Development/Promotion Mac Consulting/Sales http://www.systame.com/

« previous php.general (#124797) next »