Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Block of text with both types of quotes as a string

I'm working with a site that's based on some custom templating system. Let's say that in a template I can use tag [custom_text] which will output the entire block of html like this, defined through the CMS's rich text editor:

<b>Lorem ipsum dolor</b> sit amet, "consectetur adipisicing elit"<br /><br />
<b>sed doeiusmod</b> tempor incididunt ut's labore et dolore magna's aliqua.

Please note that it contains both types of quotes in it. I am not able to preprocess anything that comes out of the templating system other than actually outputting it to the page, as the CMS with templating system is encoded.

Now I actually need to manipulate that block, for instance to remove all the line breaks from the code. I can use php on the page, but I cannot define a string that would contain that block of code. If I do it either way:

$string = "[custom_text]";
$string = '[custom_text]';

the quotes in the block will come in the way, ending the string prematurely. Is there any obvious way to handle this issue?

like image 946
prezes Avatar asked Sep 11 '12 03:09

prezes


1 Answers

Don't know why I haven't thought of this before, but I can simply use the heredoc syntax.

$string = <<<EOT
[custom_text]
EOT;

will solve the case.

like image 104
prezes Avatar answered Sep 28 '22 06:09

prezes