Jump to content

Removing img tag


ayok

Recommended Posts

Hi, I've been creating a news site which shows the news list on the front page with some parts of the news content. So I cut the news and people can click on "complete news" button to see the detail.

 

My problem is when there are images inside the news which are also shown in the news list. What I have to do is to remove the img tag from the list so the image will not be shown. Recently I used str_replace to remove the "<img src=", "align=", etc. However I cannot remove the whole text inside <img>. My question is how can I remove those? I have tried this code as well

<?php $cutNews = preg_replace('#(<[/]?img.*>)#U',$cutNews); ?>

, but it doesn't work. It removes the whole news content.

 

Anybody has a solution for me??

Thank you,

ayok

Link to comment
https://forums.phpfreaks.com/topic/129926-removing-img-tag/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.