468,247 Members | 1,323 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

Split: How to detect a line break within a form

Hi.

I've got a textarea form and send a text via 'POST' to a PHP code:
-------------
data1
data2
data3
--------------

I use this piece of code:
-------------
$data = $_REQUEST["data"];
$data_array = split('\\n', $data);
------------

But it doesn't work. I tried also with '\n', '\r\n' and '\\r\\n'
without success.

Any suggestion? Regards.

Jul 17 '05 #1
3 7596
fr**********@europe.com wrote:
I use this piece of code:
-------------
$data = $_REQUEST["data"];
$data_array = split('\\n', $data);
------------

But it doesn't work. I tried also with '\n', '\r\n' and '\\r\\n'
without success.


For some reason its working quite fine for me with this:

textarea.php:
-------------
<?php
$sent = $_REQUEST[sent];
if($sent == "yes") {
$data = $_REQUEST[data];
$data_array = split("\n", $data);
print_r($data_array);
} else {
echo "<form action='textarea.php' method='post'>";
echo "<textarea cols='10' rows='10' name='data'></textarea>";
echo "<input type='hidden' name='sent' value='yes'>";
echo "<input type='submit' value='Send'>";
echo "</form>";
}
?>
-------------

It produces this:

Array
(
[0] => data1
[1] => data2
[2] => data3
)

What exactly is going wrong?

Zilla.

--
Remove the capital letters
in my e-mail to write to me.
Jul 17 '05 #2
On Wed, 20 Apr 2005 14:07:14 +0200, Zilla wrote:
$data_array = split("\n", $data);


" vs. '

--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #3
fr**********@europe.com wrote:

I use this piece of code:
-------------
$data = $_REQUEST["data"];
$data_array = split('\\n', $data);
------------


/me thinks:

$data_array = split("\n", $data);

HTH

C.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Martin Dieringer | last post: by
3 posts views Thread by Kubik | last post: by
6 posts views Thread by Senthil | last post: by
5 posts views Thread by Sen Haerens | last post: by
8 posts views Thread by Flyzone | last post: by
1 post views Thread by Gordon | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.