php - Using Laravel 5, How to detect carriage returns and insert line break -


i'm following excellent laravel guide on laracasts , have gotten point we're outputting song titles mysql database in video 7.

i wanted go ahead , add lyrics i've done fine.

now i'd format little better, add new lines required.

i've attempted use str_replace in view in manner;

<p>{{str_replace("\r","\n", $song->lyrics)}}</p> 

but nothing appears happen. if use
instead of \n, can see carriage return detected in correct places, output appears this;

looking oh pretty,<br> i've got find way.<br> 

where < br>'s output normal text.

can tell me if i'm approaching in right way? i've tried double , triple curly braces , think may forgetting mentioned exclamation mark, can't seem find mentioned again.

any appreciated.

in laravel 5 should use {!! !!} output variable without escaping:

{!! str_replace("\r","\n", $song->lyrics) !!}  

read more: http://laravel.com/docs/master/upgrade#upgrade-5.0 (blade tag changes section)


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -