How to change "It's" to "It is" (without apostrophe) using str_replace?

I want to replace from Facebook's relationships string "It's complicated" to other text.

The line is like this:

$user->relationship = str_replace(array('single', 'It's complicated'), array('Soltero(a)', 'Es complicado'),$data['relationship_status']);

Using: 'It's complicated' , 'It's complicated' or 'It's complicated' , do not work.

Any suggestions?

Thanks a lot.

Regards.

Answers


If you want to use literal single quoted character ('), you have to escape them.

like:

$str = '\''; // single quote

You could try this.

$user->relationship = str_replace(array('single', 'It\'s complicated'), array('Soltero(a)', 'Es complicado'),$data['relationship_status']);

The PHP could not recognize the single literal quoted character (') without escape sequences character. Here is the explanation about it: Strings literal

It's also happen for double literal quoted character (").


Need Your Help

Flash optimisation confusion

actionscript-3 optimization

I'm new to Actionscript (v3), 20 years C++ though, and I'm just trying to get my head around some of the performance caveats I'm reading.

How can I remove multiple "[" in HTML Tag ID attribute with Regex?

php regex preg-replace

How can I remove multiple "[" in HTML Tag ID attribute with Regex?