This is the HTML code:
<div class="comment-content" contenteditable="true">
Hello all<br/>
<img alt="" class="emojioneemoji" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/1f602.png">
<img alt="" class="emojioneemoji" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/1f602.png">
<img alt="" class="emojioneemoji" src="https://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/1f602.png">
</div>
I want a PHP code to search content if it images and replaces the images with their alt attribute.
I want the output to be:
<div class="comment-content" contenteditable="true">
Hello all<br/>
</div>
I try to make this by using Regex and this is my code but it's not working:
preg_replace('/<img.*?alt="(.*?)"[^\>]+>/g', '$1', $comment_content)
Any guide really appreciate.
Thank you.