note 58445 added to function.split
| From: | franz at fholzinger dot com | Date: | Fri, 04 Nov 2005 12:34:13 +0000 |
| Subject: | note 58445 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98068@lists.php.net to get a copy of this message | ||
The example from ramkumar rajendran did not work.
$line = split("/\n", $input_several_lines_long);
I do not know why this does not work for me.
The following has worked for me to get a maximum of 2 array parts separated by the first new line
(independant if saved under UNIX or WINDOWS):
$line = preg_split('/[\n\r]+/',$input_several_lines_long,2);
Also empty lines are not considered here.
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58445
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58445&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58445&report=yes
Search -- http://master.php.net/manage/user-notes.php