gpt4 book ai didi

php - preg_replace all img tags with else 东西

转载 作者:行者123 更新时间:2023-11-28 16:46:53 24 4
gpt4 key购买 nike

所以基本上我需要做的就是全部替换

<img src="random image goes here" class="random class goes here" alt="random alt goes here" />

<table>
<a href="#">src="random image goes here" class="random class goes here" alt="random alt goes here" /></a>
</table>

在内容中。我试着用 preg_replace 来做,但没有成功,也许你可以尝试帮助我?

这是我试过的-

$content = preg_replace('/"><img class=/', '"><table class="image-caption aligncenter"><tr><td><div><a href="#" target="blank"><img class=', $content);
$content = preg_replace('/ \><\a>/i', ' /></a></div></td></tr></table></a>', $content);

最佳答案

缺乏更好的上下文:

$content = preg_replace(
'/(<img[^>]+>)/',
"<table><tr><td><a href=\"#\">$1</a></td></tr></table>",
$content
);

检查 http://php.net/manual/en/function.preg-replace.php

关于php - preg_replace all img tags with else 东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9178428/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com