I want to have a user type in several lines into a textarea and then have php assign them to an array, however the code I have seems to assign blank values to the array
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtm$
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Juniper to IOS Translator</h1>
<form method="post" action="query.php">
<textarea name="txtarea" style="width: 80%; height: 25em;">
</textarea>
<input type="submit" />
</form>
PHP:
<?php
$text = $_POST["txtarea"];
echo nl2br($text);
echo "<br />" , "<br />";
$data = preg_split("/((?<=\n).*?(?=\n))/", $text , -1, PREG_SPLIT_NO_EMPTY);
print_r(array_values($data));
?>
</body>
</html>
With the input:
Line with stuff
Line with stuff more
Line with stuff more more
Line with stuff more more more
Line with stuff more more more more
I get the output:
Line with stuff
Line with stuff more
Line with stuff more more
Line with stuff more more more
Line with stuff more more more more
Array ( [0] => [1] => [2] => [3] => [4] => [5] => )
am I passing the array wrong? is my regex wrong?