extra lines being processed in textarea
<p>please help...users are pasting values in textarea which results to adding a new line...that new line is being processed and being uploaded to db but does not have values on some columns...how can i eliminate the extra lines prior to processing the textarea and upload to db?</p>

<p>here is my code that process the textarea into arrays:</p>

<pre><code>$PhoneNumber = array_map('mysql_real_escape_string', explode("\r\n", $_POST['PhoneNumber']));
$Createdate = array_map('mysql_real_escape_string', explode("\r\n", $_POST['Createdate']));
$RemedyTicketNo = array_map('mysql_real_escape_string', explode("\r\n", $_POST['PhoneNumber']));
</code></pre>

<p>//Determine the values with the least amount of elements</p>

<pre><code>$min_count = min(count($PhoneNumber), count($Createdate), count($RemedyTicketNo));
</code></pre>

<p>//Create array to hold INSERT values</p>

<pre><code>$values = array();
</code></pre>

<p>//Create the INSERT values</p>

<pre><code>for($index=0; $index&lt;$min_count; $index++)
{
$values[] = "('{$RemedyTicketNo[$index]}','{$PhoneNumber[$index]}','{$Createdate[$index]}',
'$Category2','$Category3','$Status','$Date','$Severity','$BanType','$XiD')";   
}
</code></pre>

<p>//inserting to db</p>

<pre><code>if (isset($RemedyTicketNo)) 
{
$sql="INSERT into tbl_main
(ars_no,phone_number,create_date,category_1,category_2,status,resolved_date,trouble_type_priority,ban_type,employee_id_name)
VALUES " . implode (',',$values); 
$result=mysql_query($sql);
</code></pre>

<p>im trying to incorporate this code...but its just doesn't seem to work...</p>

<pre><code>$lines = preg_split('/\n+/', trim($_POST['textarea']));
$text = implode("\n", $lines);
</code></pre>

<p>here's how my code looks like when i modify it with the code above:</p>

<pre><code>$PhoneNumber = preg_split('mysql_real_escape_string', '/\n+/', trim("\r\n", $_POST['PhoneNumber']));
$Createdate = preg_split('mysql_real_escape_string', '/\n+/', trim("\r\n", $_POST['Createdate']));
$RemedyTicketNo = preg_split('mysql_real_escape_string', '/\n+/', trim("\r\n", $_POST['PhoneNumber']));


if (isset($RemedyTicketNo)) 
{
$sql="INSERT into tbl_main
    (ars_no,phone_number,create_date,category_1,category_2,status,resolved_date,trouble_type_priority,ban_type,employee_id_name)
VALUES " . implode ('\n',$values); 
$result=mysql_query($sql);
</code></pre>
