PHP - 从字符串中删除 标签

2023-12-02

嘿,我需要删除字符串中的所有图像,但我找不到正确的方法。

这是我尝试过的,但它不起作用:

preg_replace("/<img[^>]+\>/i", "(image) ", $content);
echo $content;

有任何想法吗?


尝试删除\在......面前>.

编辑:我刚刚测试了你的正则表达式,它工作正常。这是我用的:

<?
    $content = "this is something with an <img src=\"test.png\"/> in it.";
    $content = preg_replace("/<img[^>]+\>/i", "(image) ", $content); 
    echo $content;
?>

结果是:



this is something with an (image)  in it.
  
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

PHP - 从字符串中删除 标签 的相关文章

随机推荐