1

I want to search the foullowing a

<style type='text/css\'> 

and replace it with 'text/css'

i am using

$filenew = str_replace("'text/css\'" , "'text/css'", $filenew);

But it isn't working, How shall i make it to work ?

How do you use an escape character. is there some application that generates the code like this ?

2 Answers 2

1

A \ is special in a string used for escaping and to define escape sequences. To mean a literal \ you need to escape it with another \ that is \\.

$filenew = str_replace("'text/css\\'" , "'text/css'", $filenew);
                                 ^^
Sign up to request clarification or add additional context in comments.

1 Comment

IS there some application that helps me with these kind of codes ?
0

If this is the only possible string that you may be replacing, the code below will work

$filenew = str_replace("'text/css\\'" , "'text/css'", $filenew);

you have to escape the slash itself.

I strongly suggest that you look closely at text in question to make sure that there are no unwanted replacements.

1 Comment

Thanks it worked .. :) IS there some application that helps me with these kind of codess ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.