Hello

I Need Something In My Text Area Field

When Someone Click On {{ Enter }}

It Put A Break Line Between Rows

Like Any Editors

i Was Using Ckeditor But All I Need Is Break-line Between Rows

Example

When I Write

I Love Daniweb
I Respect Daniweb Members
I Wish To learn Everyday

It Show Like This

I Love Daniweb I Respect Daniweb Members I Wish To learn Everyday

I Hope I Explained My Problem

Recommended Answers

All 5 Replies

If I understand correct - Have you tried:

nl2br($your_text_here);

Klemme

commented: Thanks ^^ +3

If I understand correct - Have you tried:

nl2br($your_text_here);

Klemme

Thanks For Help I Will Explain More

You Know ckeditor

Lets Say i Wrote

" Hello Klemme " And Clicked Enter

In Database It Will be Like This

<p > Hello Klemme </ p> Without Spaces

Thats All I Need To Do

Member Avatar for diafol

So you want to build your own text editor?
You could split the text on \n to create an array of lines
Then you can array_map or implode with "</p>\n<p>" and place a "<p>" a the start and a "</p>" at the end:

$text_array = explode("\n",$textbox_text);
$db_text = "<p>" . implode("</p>\n<p>", $text_array) . "</p>";

...store ... $db_text to db ...

Trouble is, you'll need to take off all <p> and </p> when loading this text back into the editor:

$text_to_editor = str_replace(array("<p>","</p>"),"",$text_from_db);

...load text to editor...

So you want to build your own text editor?
You could split the text on \n to create an array of lines
Then you can array_map or implode with "</p>\n<p>" and place a "<p>" a the start and a "</p>" at the end:

$text_array = explode("\n",$textbox_text);
$db_text = "<p>" . implode("</p>\n<p>", $text_array) . "</p>";

...store ... $db_text to db ...

Trouble is, you'll need to take off all <p> and </p> when loading this text back into the editor:

$text_to_editor = str_replace(array("<p>","</p>"),"",$text_from_db);

...load text to editor...

Thanks Sir For Your Help I Will Try It

You Got What I Need Thx Again

Member Avatar for diafol

Did it work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.