Forum Moderators: coopster

Message Too Old, No Replies

How to detect "Enter"/<br> in php

         

opiston

6:38 am on Aug 29, 2005 (gmt 0)

10+ Year Member



Hi all,
I have a text box for users to fill in.
Let's say the user inputs:
Hi,
how are you?
nice meeting you

I stored the user input into a database and it comes out to be like this:

Hi, how are you? nice meeting you

I know that in C++, python and other languages, "Enter" can be detected by using read() with "/n" or readline().
However, the server that I am working on does not seem to have readline installed on it.
Whenever, I try to call readline, the server gives me this error:

Call to undefined function: readline()

So I was wondering if there is another way to detect "Enter" in php.

Best Regards
Opiston

dreamcatcher

10:41 am on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Indeed there is:

[uk.php.net...]

dc

opiston

3:57 pm on Aug 29, 2005 (gmt 0)

10+ Year Member



Hi dreamcatcher,

My problem is solved.
You've been extremely helpful recently. I saw you replied several post in the past couple days.
Thanks again for helping.

Best Regards
Opiston

dreamcatcher

7:12 pm on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No problem opiston, you`re very welcome. :)

dc

DaButcher

7:03 am on Aug 30, 2005 (gmt 0)

10+ Year Member



btw!
In some cases, you might want the output, as it was typed in.. You have a html-tag called <pre></pre> (cheating(?))

I prefer not using <pre></pre>, as it might provoke the design of the CMS, if there is no overflow setting in the content container.

anyhow.. it's also \n, not /n.
You also have \t, etc.

it's good practice to use them, when parsing html via php.

example:


echo "<table>\n
<tr>\n
\t<td></td>\n
</tr>\n
</table>";

As this will make your source-code much easier to read, rather than having it all in one line.