title: Beginner PHP scraping help - getting img src?
body: <p>I am currently trying to increase my knowledge of PHP and I have set myself the task of scraping a website and turning the data I retrieve into a JSON format.</p>
  
  <p>Here is an example row of the data I am trying to parse:</p>
  
  <pre><code> &lt;tr&gt;
   &lt;td class="first"&gt;
       &lt;img id="ctl00_Content_ctl00_rptInfo_ctl01_Image1" alt="Active" src="../../images/t1.jpg" style="border-width:0px;" /&gt;              
   &lt;/td&gt;
   &lt;td &gt;
        Copenhagen
   &lt;/td&gt;
   &lt;td&gt;
        Sas
   &lt;/td&gt;
   &lt;td&gt;
       SK537
   &lt;/td&gt;
   &lt;td&gt;
       02 Apr 10:20
   &lt;/td&gt;
   &lt;td class="last"&gt;
       Delayed 11:30
   &lt;/td&gt;
   &lt;/tr&gt;
  </code></pre>
  
  <p>And here is my PHP code so far:</p>
  
  <pre><code>$raw = file_get_contents($url);
  
  $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
  $content = str_replace($newlines, "", html_entity_decode($raw));
  
  $start = strpos($content,'&lt;table width="100%" cellspacing="0" cellpadding="0" border="0" summary="Departure times detail information"');
  
  $end = strpos($content,'&lt;/table&gt;',$start) + 8;
  
  $table = substr($content,$start,$end-$start);
  
  preg_match_all("|&lt;tr(.*)&lt;/tr&gt;|U",$table,$rows);
  
  foreach ($rows[0] as $row){
  
      if ((strpos($row,'&lt;th')===false)){
  
          preg_match_all("|&lt;td(.*)&lt;/td&gt;|U",$row,$cells);
  
          $url_src = strip_tags($cells[0][0]);
  
          $airport = strip_tags($cells[0][1]);
  
          $airline = strip_tags($cells[0][2]);
  
              $flightnum = strip_tags($cells[0][3]);
  
              $schedule = strip_tags($cells[0][4]);
  
              $status = strip_tags($cells[0][5]);
  
          echo "{$url_src} - {$aiport} - {$airline} - {$flightnum} - {$schedule} -  {$status}&lt;br&gt;\n";
  
      }
  
  }
  </code></pre>
  
  <p>I can currently get nearly all values correctly except I cannot seem to get anything for the cell that contains this:</p>
  
  <pre><code>&lt;td class="first"&gt;
       &lt;img id="ctl00_Content_ctl00_rptInfo_ctl01_Image1" alt="Active" src="../../images/t1.jpg" style="border-width:0px;" /&gt;              
  &lt;/td&gt;
  </code></pre>
  
  <p>Can anyone help me out with what I need to get the img string, I would be happy just being able to get the entire string within the <code>&lt;td&gt;&lt;/td&gt;</code> like this:</p>
  
  <p><code>&lt;img id="ctl00_Content_ctl00_rptInfo_ctl01_Image1" alt="Active" src="../../images/t1.jpg" style="border-width:0px;" /&gt;</code></p>
  
  <p>But if its possible to parse out just the src string that would be very helpful.</p>