i get from db a text like this.
{br}{/br}hello!{br}{/br}
this text is outputted inside a textarea element.
what i need is to replace all the '{br}{/br}' with invisible char '\n' which should set a enter space in the textarea itself. hoping 🙂
what i tryed to do is.
$text = str_replace('{br}','\n',$text);
$text = str_replace('{/br}','\n',$text);
then output $text in textarea, but chars \n are visible 😐
Use
str_replacewith a double quoted"\n"for it to be interpreted as a newline;'\n'with single quotes is a literal backslash followed by ann.I’m not sure why you’re calling
str_replaceonce for{br}and once for{/br}. Do you want each pair of{br}{/br}to be replaced by two new lines? If so, you could do that more simply with a single call: