Page 1 of 1

Clearing an Array

Posted: Sun Oct 13, 2002 2:35 pm
by Zoram
I am working on a loop that lists email addresses for each row. right now i have the following code to explode the email addresses :

Code: Select all

// Email Filter
	!$email?$emailArray = "":$emailArray = explode(", ",$email); 
	if ($email != "") {
  	while (list($index,$email) = each ($emailArray)) 
  	{ 
    	$Emails .= "<a href="mailto:$email">$email</a> "; 
  	&#125; // while
	&#125; else &#123;
		$Emails = "No Email Listed";
	&#125;
it works fine, but i each row it just adds to the $emailArray and multiplies and conquers :) Any Ideas on how to make it clear the array each time?

Posted: Sun Oct 13, 2002 10:50 pm
by volka
  • have to admit I do not understand
  • the question
  • the script
but anyway

*bump* ;)

...

Posted: Sun Oct 13, 2002 11:25 pm
by QWERTY

Code: Select all

unset ( $array );

?

Posted: Mon Oct 14, 2002 5:20 pm
by Zoram
Nope :D Thanks for the suggestion though.

I guess that i didn't phrase that question very well...

Page

I have on there a list of email addresses for each of the staff. I have in my database a field for email addresses, for each email address a person has (separated by ", ") i want it to be a link. I got it so that it that it breaks up the email addresses and links them, but it justs adds to the array when it loops through to the next staff member and add theirs to the existing list.

Hope that helps a little ;)

Posted: Mon Oct 14, 2002 5:30 pm
by volka

Code: Select all

...
while ($row = mysql_fetch_assoc($result))
{
	...
	$emailArray = $row&#1111;'eAddrs'] ? explode(',', $row&#1111;'eAddrs']) : array();
	foreach($emailArray as $email)
		echo '&lt;a href="mailto:', $email, '"&gt;', $email, '&lt;/a&gt;', ... ;
	...
}
...