• 0

PHP Convert Straight Quotes to Smart Quotes.


Question

Using PHP, how would I convert the following:

I "love" Newoin

to the following?

I “love” Newoin

Do you see the use of smart quotes?

 

I can do this in JS but I need to do this in PHP.  In JS, I'd do something like...

$text = 'I "love" Newoin';
console.log($text.replace(/'/g, "’").replace(/\`/g, "’").replace(/\b"/g, "”").replace(/\"/g, "“"));

But I have no idea how to do this in PHP.  Please help. Thanks.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

This topic is now closed to further replies.