Friday 14 November 2014

Converting php version of \r\n to line breaks in a textarea (without using a
tag)

If you are using a text area for input form field and you want to display the output on view/edit version, and if sometimes find \r\n is displaying instead of line breaks;

This could be because of single quote string format, in such case even if you use nl2br() function, it wouldn't work either. In such case, you may need to use the double quotes on str_replace which interesting would work.

Please use the below format in such case;


$yourStringHere = str_replace('\r',"\r",str_replace('\n',"\n",$yourStringHere));

echo '';

No comments:

Post a Comment

Please post any queries and comments here.