Closed Thread Icon

Preserved Topic: replace all images preg_replace (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21092" title="Pages that link to Preserved Topic: replace all images preg_replace (Page 1 of 1)" rel="nofollow" >Preserved Topic: replace all images preg_replace <span class="small">(Page 1 of 1)</span>\

 
Bueromuenchen
Bipolar (III) Inmate

From: San Jose, CA
Insane since: Nov 2000

posted posted 07-14-2002 19:34

ok, this might be easy for you guys,
but i didn't manage

i have html in an string called $content (it's not big)

i want to strip out all the images in this $content
for example:

tags:
<img src="../img/km3.gif" width="9" height="22">

and td backgrounds:
background="../img/whatever.gif"

can you help me?

thanks flo


someoneInverse
Bipolar (III) Inmate

From:
Insane since: May 2002

posted posted 07-15-2002 08:29

I guess that the easiest and most accurate way to do this would be to load $content as an xml document (assuming that the html is well formed and conforms to xhtml standards) and delete any img nodes from there
hth
I:.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 07-15-2002 08:59

your regular expression for removing the <img> tag is: <img[^>]+>

and for removing the <td>'s background is:
(<td.+?)background="[^"]+"([^>]*> )
and replacing it with \1 and \2 (what is before the background and what comes after it).



[This message has been edited by lallous (edited 07-15-2002).]

« BackwardsOnwards »

Show Forum Drop Down Menu