954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

table contents grep using preg

Hi all,
I am dealing a small issue. I am missing something silly :). My need is that I want the entire lines between with no modifications.

<?php

$some_string = <<<STR
<HR noShade size=2>
<TABLE  BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR="" >
<TR BGCOLOR="c1ffcc">
<TH ALIGN="LEFT" COLSPAN=22>
<font face="Arial,Helvetica,Geneva,Swiss,Verdana" size="2" color="black">Baseline Comparison for Request Id: </font></TH>
</TR>
<TR BGCOLOR="lightblue">
<TH COLSPAN=1>
</TH>
</TABLE>
</body>
</html>
STR;

$match = preg_match('`<TABLE  BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR="" > (.*)</TABLE>`i', $some_string,$table);

echo $match;

print_r($table);


But this code doesn't fetch me the desired output. Any help will be highly appreciated.

sugumarclick
Light Poster
39 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

What is the output you get, and what is the output you want ?

If you look at the manual , you can see that $match is an integer. If you want to get the text, you'll need to use $table[1] (assuming your regex is correct).

pritaeas
Posting Expert
Moderator
5,483 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: