I am looking to create a system which on signup will create a subdomain on my website for the users account area.
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
Cisco Certified Network Associate Exam,640-802 CCNA All Answers ~100/100. Daily update
I would like to replace the following:
="Dark4Red"
with
=\"Dark4Red\"
The = sign and double quotations are fixed ="..." I just need to add slashes before double quotations.
$content = preg_replace('/="[^a-zA-Z#0-9]"/', '=\"[^a-zA-Z#0-9]\"', $line);
The above solution didn't work. Any idea?
How about addslashes?
ReplyDeleteThat aside, you appear to have not read any of the examples on preg_replace's manual page - if you had, you'd have known that you capture a subpattern (in this case the contents of the quotes) with parentheses and use $1 to put them in the replacement string.
You can use
ReplyDelete$str = '"Text"';
str_replace('"','\"', $str);