HI I have a issue
I have a text box, and I need some how, that every time the user press the enter key, to make a space in the text that he types, a <br> tag is inserted at the end of the text, so when I call it back it know where to make another line PLEASE help PLEASE keep it in php if posible. thank you

Hi,

a built in function is php 4 and php 5 named nl2br means newline to breakline is used for these purposes.

you can use it like following

string1 nl2br(string2);

where string2 is the return value of nl2br with all the \n converted into br

Thanks.

can you make a example, what I have is a text box that turns in to a variable, then the variable is saved in mysql DB,

it would realy help if you make an example. please...

can you make a example, what I have is a text box that turns in to a variable, then the variable is saved in mysql DB,

it would realy help if you make an example. please...

Yeah, how about you read the link I posted. The PHP manual gives examples for almost every single function built into the language.

I need one that inputs text and makes <br> every time the user makes a new line, if I have that I dont need to make php echo <br> becuse they would be already in the text.

Evidently you're not hearing me. Click that link I posted, that's what it does, that's what it was made for, that's what you need. Read it.

I read it once, and I did not got it, then a secund time, same and a third time and nothing still, If you think you know the solution, would you just share it, cus I am new and dont understand where the text is imputed, this are the only examples they give

Example #1 using nl2br()

<?php
echo nl2br("foo isn't\n bar");
?>

The above example will output:

foo isn't<br />
bar

Example #2 Generating valid HTML markup using the is_xhtml parameter

<?php
echo nl2br("Welcome\r\nThis is my HTML document", false);
?>

The above example will output:

Welcome<br>
This is my HTML document


maybe you can explain what I am not undestanding. !!!!

From what you are saying, it sounds like you are wanting the br tags to be added as they type. This isn't possible with php. You would need to run nl2br() once the form is submitted. If you are looking for that type of solution (which would be pointless, because they would see <br /> in the textarea), look into javascript.

Thank You Kkeith29

so I would need to have the text in a variable, then do
nl2br($text);

or is this bad?

I figure it out, thanks
it is

$string=nl2br($string);

I am new in php, so any small bump becomes a big mountain...

This article has been dead for over six months. Start a new discussion instead.