Forum Moderators: coopster
I have a text box into which I enter a single email on each line. I am working on a script that will extract the email from each line.
I've been unable to figure out how to store the extracted emails into a session array so that the array can be printed out or stored into the DB in the subsequent pages.
Here is the code that extracts the emails. The storing in an array does not work..
Help would be appreciated..
TIA
<?php
$_SESSION['n_email'] = $_POST['emails'];
$_SESSION['n_email'] = explode("\n", $_SESSION['n_email']);
foreach($_SESSION['n_email'] as $v)
{
// call function to remove null or empty lines
$v = removeEmptyLines($v);
//skip blank lines
if(substr($v, 0, 1) == "")
{
continue;
}
//get the email
$email = explode("\n", $v);
// Storing this in an array does NOT work
$_SESSION['n_email'] = array($email[0]);
}
// This prints only one email
Echo "($_SESSION[n_email])";
?>
$email = $_POST['emails'];
$email = explode("\n\r", $email);
echo '<pre>';
print_r($email);
echo '</pre>';
Good luck!
$email = explode("\r\n", $email);
This thread [webmasterworld.com] may also be of interest to you.
Sorry about that ;)