I have a string coming from a language file containing strings with the text in the current language.
$str = 'blabla\n\nmore blabla';
$str is going to be used in an textarea where the \n must be a linebreak
If I place it inside double quotes this works.
The problem is that $str will always be in single quotes. I've been Googling and searching this site. There are many similar questions, but I didn't manage to find a solution.
How can I convert my single-quoted string (with a literal "\n") to a doublequoted string (where "\n" is converted to a linebreak)?
Answer
$str = str_replace('\n', "\n", $str);
No comments:
Post a Comment