Clearing an Array

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
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Clearing an Array

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

  • have to admit I do not understand
  • the question
  • the script
but anyway

*bump* ;)
User avatar
QWERTY
Forum Newbie
Posts: 20
Joined: Sat Jun 29, 2002 10:57 am
Location: Slovenia

...

Post by QWERTY »

Code: Select all

unset ( $array );

?
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post 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 ;)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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;', ... ;
	...
}
...
Post Reply