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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 preg_replace("/<img[^>]+?>/","",$html,1); Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.