任务是用标签和属性替换<img>
给定字符串中的所有标签作为内部文本。在寻找答案时,我发现了类似的问题<div>
src
<?php
$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.
问题:如何升级脚本ant得到这个结果:
this is something with an <div>test.png</div> in it.