HTML Code:
<table >
  <tr>
    <td></td>
  </tr>
  <tr>
    <td class=\"Contents\">
		<p>Large Paragraph1....</p>
		<p>Large Paragraph1....</p>
		<p>Large Paragraph1....</p>
		<p>Large Paragraph1....</p>
	</td>
  <tr>
    <td class=\"Contents\">
		<p>Large Paragraph 2</p>
		<p>Large Paragraph 2</p>
		<p>Large Paragraph 2</p>
		<p>Large Paragraph 2</p>
		<p>Large Paragraph 2</p>
	</td>

  </tr>
</table>
I want to get contents of cell which contains ID as MainCell.
So I have wrote a sample php code like this
PHP Code:

<?php $html="<table >
  <tr>
    <td></td>
  </tr>
  <tr>
    <td class=\"Contents\">
        <p>Large Paragraph1....</p>
        <p>Large Paragraph1....</p>
        <p>Large Paragraph1....</p>
        <p>Large Paragraph1....</p>
    </td>
  <tr>
    <td class=\"Contents\">
        <p>Large Paragraph 2</p>
        <p>Large Paragraph 2</p>
        <p>Large Paragraph 2</p>
        <p>Large Paragraph 2</p>
        <p>Large Paragraph 2</p>
    </td>

  </tr>
</table>"
;


    
preg_match_all('#<td class=\"Contents\">(.+?)</td>#'$html$MainHeads);


echo 
"<table>";
    foreach (
$MainHeads[1] as $Contents
    {
    echo(
"<tr>");
    echo(
"<td>.$Contents.</td>");
    echo(
"</tr>");
    }
echo 
"</table>";
?>
But this is not working, What's wrong on this code?



Note: When I change $html like this

PHP Code:
$html="<table >
  <tr>
    <td></td>
  </tr>
  <tr>
    <td class=\"Contents\"><p>Large Paragraph1....</p></td>
  <tr>
    <td class=\"Contents\"><p>Large Paragraph 2</p></td>
  </tr>
</table>"

It is working