You can use preg_split
to do that.
$arr = preg_split('/[
]+/', $textareaInput);
It splits it on any combination of the
or
characters. You can also use s
to include any white-space char.
Edit
It occurred to me, that while the previous code works fine, it also removes empty lines. If you want to preserve the empty lines, you may want to try this instead:
$arr = preg_split('/(
|[
])/', $textareaInput);
It basically starts by looking for the Windows version
, and if that fails it looks for either the old Mac version
or the Unix version
.
For example:
<?php
$text = "Windows
Mac
Unix
Done!";
$arr = preg_split('/(
|[
])/', $text);
print_r($arr);
?>
Prints:
Array
(
[0] => Windows
[1] =>
[2] => Mac
[3] =>
[4] => Unix
[5] =>
[6] => Done!
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…