title: Getting data from html file and print using php
body: <p>My scenario is,</p>
  
  <ol>
  <li><p>Read html page content using php</p></li>
  <li><p>Retrieving the required data from the html using DOM parser concept by using php</p></li>
  <li><p>Displaying the retrieved data in the same php page (the content as like in html page)</p></li>
  </ol>
  
  <p>I have done all 3 steps, but while displaying the data i didn't get my required format,
  Here is all of my code (html,php):</p>
  
  <p>Html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;data&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table border='1'&gt;
      &lt;tr&gt;&lt;th&gt;Place&lt;/th&gt;&lt;th&gt;Temperature&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='date'&gt;25-08-2011&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='city'&gt;A&lt;/td&gt;&lt;td class='temp'&gt;30 c&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='city'&gt;B&lt;/td&gt;&lt;td class='temp'&gt;29 c&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='date'&gt;26-08-2011&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='city'&gt;A&lt;/td&gt;&lt;td class='temp'&gt;28 c&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td class='city'&gt;B&lt;/td&gt;&lt;td class='temp'&gt;28 c&lt;/td&gt;&lt;/tr&gt;  
  &lt;/table&gt;        
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Php code:</p>
  
  <pre><code>&lt;?php
  include('simple_html_dom.php');
  $html = file_get_html('data.html');
  
  $sdate[0]="";
  $city[0]="";
  $temp[0]="";
  $c=0;
  
  foreach($html-&gt;find('td[class=date]') as $e)
  {
      $sdate[$c]=$e-&gt;innertext;
      $c=$c+1;
  }
  
  $c=0;
  foreach($html-&gt;find('td[class=city]') as $e)
  {
      $city[$c]=$e-&gt;innertext;
      $c=$c+1;
  }
  
  $c=0;
  foreach($html-&gt;find('td[class=temp]') as $e)
  {
      $temp[$c]=$e-&gt;innertext;
      $c=$c+1;
  }   
  for($i=0;$i&lt;$c;$i++)
  {
      echo 'Date:'. $sdate[$i]."&lt;br&gt;";
      echo 'City:'.$city[$i]  .', Temp:' . $temp[$i]."&lt;br&gt;" ;
  }
  
  ?&gt;
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Date:25-08-2011
  City:A, Temp:30 c
  Date:26-08-2011
  City:B, Temp:29 c
  Date:
  City:A, Temp:28 c
  Date:
  City:B, Temp:28 c
  </code></pre>
  
  <p>But, I want to print the result like this format,</p>
  
  <pre><code>Date:25-08-2011
  City:A, Temp:30 c
  City:B, Temp:29 c
  Date:26-08-2011
  City:A, Temp:28 c
  City:B, Temp:28 c
  </code></pre>
  
  <p>Please anybody help me...</p>
  
  <p>Thanks,
  Nandha</p>