title: filter img src to remove file in directory, How to cut the array remove file in php
body: <p>I have a html structure like below, it is random div tag and img tag, and these also store in database too.<br>
  Now I have to filter the img src in below string,  to remove files not in this structure but store in directory,<br>
  whats the best way to get the src in this structure in frontend use jquery or server side use php.<br>
  Any suggestion how to do this?  Thanks so much!!</p>
  
  <p>in frontend</p>
  
  <pre><code>&lt;div class="h1"&gt;content&lt;div&gt;
  &lt;div class="h1" style=""&gt;content&lt;/div&gt;
  &lt;div class="h1" style=""&gt;...&lt;/div&gt;
  &lt;div class="h2"&gt;...&lt;/div&gt;
  &lt;div class="h1" style=""&gt;content&lt;/div&gt;
  &lt;img src="u_img/5/1.png" style="" class=""&gt;
  &lt;div class="link" style=""&gt;link: http://...&lt;/div&gt;
  &lt;img src="u_img/5/14.jpeg" style="" class=""&gt;
  &lt;div class="h1" style=""..&lt;/div&gt;
  &lt;img src="u_img/5/3.png" style="" class=""&gt;
  </code></pre>
  
  <p>in database</p>
  
  <pre><code>&lt;div class="h1"&gt;content&lt;div&gt;&lt;div class="h1" style=""&gt;content&lt;/div&gt;&lt;div class="h1" style=""&gt;...&lt;/div&gt;&lt;div class="h2"&gt;...&lt;/div&gt;&lt;div class="h1" style=""&gt;content&lt;/div&gt;&lt;img src="u_img/5/1.png" style="" class=""&gt;&lt;div class="link" style=""&gt;link: http://...&lt;/div&gt;&lt;img src="u_img/5/14.jpeg" style="" class=""&gt;&lt;div class="h1" style=""..&lt;/div&gt;&lt;img src="u_img/5/3.png" style="" class=""&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong><br>
  if I get those img src in frontend store in array post via jquery to php file like below, then how to delete those file not in this array</p>
  
  <pre><code>var srcArray=$('img').map(function(){
      return $(this).attr('src');
  });
  var fd = new FormData(uf[0]);
  fd.append('srcArray',srcArray);
  $.ajax({
      type: "POST", url: "img_clean.php",
      data: fd,
      processData: false, contentType: false,
  })
  </code></pre>
  
  <p>php</p>
  
  <pre><code>$srcArray = $_POST['srcArray']; 
  
  //How to delete file not in the array?
  
  foreach($srcArray as $row){
      $dir = "u_img_p/".$id;  
          //unlink($dir.'/'.$row);
      } 
  }
  </code></pre>