开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜