I want to replace the image tags in the string with their src
attributes respectively....
I have this code
$url='<img class="emojioneemoji" src="http://localhost/sng/assets/js/plugins/em/2.1.4/assets/png/1f602.png">checking<img class="emojioneemoji" src="http://localhost/sng/assets/js/plugins/em/2.1.4/assets/png/1f601.png">now<img class="emojioneemoji" src="http://localhost/sng/assets/js/plugins/em/2.1.4/assets/png/1f62c.png"><img class="emojioneemoji" src="http://localhost/sng/assets/js/plugins/em/2.1.4/assets/png/1f600.png">';
$doc = new DOMDocument();
@$doc->loadHTML($url);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
$img_path = $tag->getAttribute('src');
$directory = $img_path;
$ee = pathinfo($directory);
$pic_name= $ee['basename'];
preg_replace("/<img[^>]+\>/i", " ", $pic_name);
}
echo $url;
?>
I want to get output like this:
-1f602.png-checking-1f601.png-now-1f62c.png-1f600.png-