Kay
Kay

Reputation: 845

PHP convert double quoted string to single quoted literal string

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 interested: htmlspecialchars does the job.

Cheers, Kay

Upvotes: 0

Views: 1125

Answers (1)

John Cartwright
John Cartwright

Reputation: 5084

Unless I misunderstood, would a simple string substitution work?

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

Upvotes: 1

Related Questions