php get src value from img tag code example

Example 1: php get src content from image tag

$html = '<img id="12" border="0" src="/images/image.jpg"
         alt="Image" width="100" height="100" />';

$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$src = $xpath->evaluate("string(//img/@src)"); # "/images/image.jpg"

Example 2: img src php

<?php

while($row = mysqli_fetch_array($result)){

                          echo ' 
                              <tr>      
                              <td> '.$row['x'].' </td>
                              <td> '.$row['y'].' </td>
                              <td> '.$row['z'].' </td>
                              <td> '.$row['f'].' </td>
                              <td> '.$row['g'].' </td>
                              <td> '.$row['d'].' </td>
                              <td><img src="'.$url.'"/></td>
                              </tr>';
}
?>

Tags:

Php Example