开发者

How to replace <span style="font-weight: bold;">foo</span> by <strong>foo</strong> using PHP and regex?

开发者 https://www.devze.com 2022-12-28 05:42 出处:网络
I have a string like this: &l开发者_StackOverflowt;span style=\"font-weight: bold;\">Foo</span>

I have a string like this:

&l开发者_StackOverflowt;span style="font-weight: bold;">Foo</span>

I want to use PHP to make it

<strong>Foo</strong>

…without affecting other spans.

How can I do this?


$text='<span style="font-weight: bold;">Foo</span>';
$text=preg_replace( '/<span style="font-weight: bold;">(.*?)<\/span>/', '<strong>$1</strong>',$text);

Note: only work for your example.

0

精彩评论

暂无评论...
验证码 换一张
取 消