Any body please help me. I stuck my self in the world of regular expressions 🙁 and lost.
I have 2 tables like and using the regular expression preg_match_all I am trying ti get the data in between the table like every thing in between the tables
<table bgcolor=cccccc width=100%>
<tr>
<td>
Some title here
<td>
</tr>
<tr>
<td>inside some data will be here
<img src=images/icon2.jpg width=40 height=40>
<div class=head1>data here</div>
<h1> title here</h1>
<div class=texth>my all text here in multiline</div>
</td>
</tr>
</table>
I need to get every thing in between the tables <TD></TD> tage in this string in arrays like one table in one array[0] 2nd table in array[1].
I am using the following code
$data<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"12\">
<tr>
<td bgcolor=\"#F7F5F4\">
<div align=\"right\" ID=\"Did292558\"></div>
<h1 class=\"head1\"> title 1 here</h1>
<img src='images/imagename.jpg' align='left'>
<div class=\"story\">
<div align=\"right\"><b>my detailed text will came here</div>
</div>
</td>
</tr>
</table>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"12\">
<tr>
<td bgcolor=\"#F7F5F4\">
<div align=\"right\" ID=\"Did292558\"></div>
<h1 class=\"head1\"> title number 2 here</h1>
<img src='images/imagename.jpg' align='left'>
<div class=\"story\">
<div align=\"right\"><b>my detailed text will came here</div>
</div>
</td>
</tr>
</table>";
$pattern = '/(<([\w]+)[>]>)(.)(<\/\2>)/' ;
preg_match_all($pattern, $data, $matches);
for ($i=0; $i< count($matches[0]); $i++) {
$sho=$matches[0][$i];
echo"$i : $sho <br><br>";
}
In that case I am geting the data in arrays but the problem is that its remove the data from top. There is a problem in pattern.
What is the best way to get the data between the TD tags of each table in array[0] array[1]
or if possible to get the each table in between TD tage we can get like
<h1 class=\"head1\"> title number 2 here</h1> in one array of table 1
<div align=\"right\"><b>my detailed text will came here</div>in 2nd array of table 1
and so on for the rest of the tables in data string
I am really really stuck in it if some one can help me in that shall be very bery thankful