$var = "text<img src='/img/tag1.gif' alt='' />
text text text text text <i>-blah-blah-blah-blah-blah-blah</i>
<img src='/img/tag2.gif' alt='' />
<img src='/img/myhome.gif' alt='' />
<b>text</b> text text blah-blah-blah-blah-blah-blah-blah-blah
<img src='/img/age.gif' alt='' />";
$var = preg_replace('/(<img(.+?)>)/i', '', $var);
echo $var;
如何在本文中替換除IMG標記之外的所有文本內容?Рhppreg_replace - 刪除除html標記以外的所有文本IMG
很酷,它的工作! )) 謝謝你,兄弟! – Max 2011-05-07 00:43:26