AudiS2 Posted January 7, 2009 Share Posted January 7, 2009 I am wondering is it possible to use strip_tags to only remove the first occurrence of the tag. I have html with multiple images and I want to strip it off html and but the first image. Link to comment https://forums.phpfreaks.com/topic/139809-solved-strip_tags-questions/ Share on other sites More sharing options...
teng84 Posted January 7, 2009 Share Posted January 7, 2009 i think no.. use preg_replace or preg_match instead Link to comment https://forums.phpfreaks.com/topic/139809-solved-strip_tags-questions/#findComment-731409 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 preg_replace("/<img[^>]+?>/","",$html,1); Link to comment https://forums.phpfreaks.com/topic/139809-solved-strip_tags-questions/#findComment-731487 Share on other sites More sharing options...
AudiS2 Posted January 8, 2009 Author Share Posted January 8, 2009 My final solution was this: Replace the first img tag with iimmgg for example. perform strip_tags, return the changed tag back Thanks all! Link to comment https://forums.phpfreaks.com/topic/139809-solved-strip_tags-questions/#findComment-732323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.