Page 1 of 1

Passing element through array and back

Posted: Tue Jan 23, 2007 4:05 am
by jeffos101
arborint | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

We're trying to get the elements from an array and remove the extra stuff, only keeping the email address . Pass through the registration 
then put these back in another array...

It is for a invite your friend code where the user enter his friend email manually. 

Thank you so much for your insight. Not sure what we're doing wrong. 

J

Code: Select all

/// manual email

$emcontactz= $_POST['emailz'];
$emcontactz = substr($emcontactz, 0, 450); $rawemail = explode(",", $emcontactz); $numi = substr_count($rawemail);


$o = 0;

while($o<=$numi) {
  $rawemail[$o]=trim($rawemail[$o]);
  if(ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",$rawemail[$o]))
  $rawemailValid[]=$rawemail[($o)];
$o++;

arborint | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Jan 23, 2007 8:04 am
by feyd
What's the question?

Posted: Tue Jan 23, 2007 11:59 am
by jeffos101
what I would like to do is get the data from the array

$rawemail

clean it up to remove anything that's not an email with

ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$


then put the clean results in another array

$rawemailValid

Posted: Tue Jan 23, 2007 9:49 pm
by feyd
Okay, I'll ask it a different way: what are you, specifically, having problems with?

Posted: Wed Jan 24, 2007 12:32 pm
by jeffos101
nevermind I found the way to do it with the array_filter function

the thing that was messing up my result was a missing trim

Code: Select all

function check4email($v) 
{
if(ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",trim($v)))
	{
	return true;
	}
return false;
}


$goodmail = array_filter($rawemail,"check4email");