Reputation: 1049
I have a php variable and I had to insert into it html code with another variable. ie:
myarray['foo'] = "<p><? echo $var; ?></p>"
but in this way it doesnt' work. How could escape it correctly?
Upvotes: 0
Views: 95
Reputation: 12018
Just do:
myarray['foo'] = "<p>$var</p>"
PHP handles all the parsing for you.
EDIT:
From your comment about the array, you could print the raw contents of the array (not very helpful for an app, but fine for debugging):
myarray['foo'] = "<p>".print_r($var, true)."</p>";
Upvotes: 2