php - how to convert line breaks stored in mySQL to a single line -
I have the details stored in mySQL with Lin Brakes, so when I output them, I use it
and it shows:
line 1 line2 line3
So far, it's great. Now, I want to use the same description for the meta tag and the problem is if I like them:
$ old_string = nl2br ($ description); $ New_string = preg_replace ("/>
," ", $ old_string); Echo $ new_string;
I still find these meta tags:
How can I get it out in line 1, just with one place between them?
Thank you very much for any help.
For Meta < Code> nl2br , but instead of line breaks on the string database. Note that depending on your environment, a line break can be displayed with \ r \ n
or simply with \ n
. Try using the following code:
$ onelinestring = str_replace ("\ r \ n", "", $ description); $ Onelinestring = str_replace ("\ n", "", $ inlinestring);
Comments
Post a Comment