Passing element through array and back

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeffos101
Forum Newbie
Posts: 3
Joined: Tue Jan 23, 2007 3:59 am

Passing element through array and back

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What's the question?
jeffos101
Forum Newbie
Posts: 3
Joined: Tue Jan 23, 2007 3:59 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Okay, I'll ask it a different way: what are you, specifically, having problems with?
jeffos101
Forum Newbie
Posts: 3
Joined: Tue Jan 23, 2007 3:59 am

Post 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");
Post Reply