开发者

PHP convert double quoted string to single quoted literal string

开发者 https://www.devze.com 2023-03-13 11:03 出处:网络
Is there a way to convert the double quoted string \"<b>foo</b>\" to the single quoted string \'<b>foo</b>\'. Please note that I cannot use <?php strip_tags(\"<b>foo&l

Is there a way to convert the double quoted string "<b>foo</b>" to the single quoted string '<b>foo</b>'. Please note that I cannot use <?php strip_tags("<b>foo</b>")?>, I need to tags to be present.

EDIT: I should have asked a question, I would like to styling to be removed, I don't wish foo to be boldened - just for <b>foo</b> to be echo'd to the screen.

Solution found: For anyone intere开发者_开发技巧sted: htmlspecialchars does the job.

Cheers, Kay


Unless I misunderstood, would a simple string substitution work?

str_replace('"', "'", '"<b>foo</b>"'); //'<b>foo</b>'
0

精彩评论

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