472,341 Members | 2,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,341 software developers and data experts.

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 7730
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Martin Dieringer | last post by:
I am trying to split a file by a fixed string. The file is too large to just read it into a string and split this. I could probably use a lexer but...
2
by: Jeremy | last post by:
I have a pretty straightforward database that is designed to record free-form information about products (date, source and a memo field). This is...
1
by: pemigh | last post by:
I have a report with pages breaking in the middle of text box controls. And it's not just on a line-by-line basis, but sometimes (in a situation...
3
by: Kubik | last post by:
Hello! How to detect mouseclick anywhere on the form? There is a lot of controls on the form, so I don't want to add eventhandler for each of...
6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns =...
5
by: Sen Haerens | last post by:
I'm using string.split(/^$/m, 2) on a curl output to separate header and body. There’s an empty line between them. ^$ doesn’t seem to work... ...
8
by: Flyzone | last post by:
Hi, i have a problem with the split function and regexp. I have a file that i want to split using the date as token. Here a sample: ----- Mon...
1
by: Gordon | last post by:
I've been looking into including a system to allow logging of diffs so users can view different versions of a file and roll it back to an earlier...
5
sicarie
by: sicarie | last post by:
I am attempting to parse a CSV, but am not allowed to install the CSV parsing module because of "security reasons" (what a joke), so I'm attempting...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.