Я хочу удалить или отфильтровать некоторые значения изображений, которые не существуют, в другую строку. В переменной $ description есть 2 значения изображений (images / bk5.jpg, images / bk3.jpg), а в переменной $ img - 4 значения изображений, и я хочу $ imgs_result (images / bk5.jpg, images / bk3.jpg) и хочу чтобы удалить еще 2 изображения значений переменной $ img.
<?php
$description ='Some paragraph... <p><img src="images/bk5.jpg" alt="" width="300" height="242" /><img src="images/bk3.jpg" alt="" /> Some paragraph...</p>';
$img ='images/bk1.jpg images/bk3.jpg images/bk4.jpg images/bk5.jpg';
$imgpage = explode(" ",$img);
$imglength = count($imgpage);
for($x = 0; $x <= $imglength; $x++){
//This code delete the images from the database but does not remove or filter the values of variables.
if(!stristr($description,$imgpage[$x])){
$imgs_result = str_ireplace($imgpage[$x],"",$img);
unlink($imgpage[$x]);
}
}
?>