Torquil Beavis
asked on
How to assign string variable in php where string has both single and double quotes
Using PHP, I need to assign to a variable a long string that contains a number of single and double quotes which cause confusion when I surround the string with single or double quotes to contain it. I'm sure there must be a function to do this. However, search as I may, I cannot find one, nor contributors' solutions. These will be stored as files, not as DB records.
For example:
Clearly, the example can't work with Times New Roman contained by single or double quotes.
Is there a standard method to deal with this?
For example:
$string =
"
<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
line-height:normal;mso-outline-level:1'><b><span style='font-size:24.0pt;
font-family:"Times New Roman","serif";mso-fareast-font-family:"Times New Roman";
mso-font-kerning:18.0pt;mso-fareast-language:EN-CA'>Welcome Alpha Team!<o:p></o:p></span></b></p>
"
Clearly, the example can't work with Times New Roman contained by single or double quotes.
Is there a standard method to deal with this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome, glad to help.
ASKER