Donpro <mailto:[EMAIL PROTECTED]> on Tuesday, February 24, 2004 9:52 AM said:
> $emails = > array("[EMAIL PROTECTED]","[EMAIL PROTECTED]",[EMAIL PROTECTED]); > $addresses = explode(",",$emails); for ($i=0; $i < count($addresses); > $i++) { echo $i . ': ' . $addresses[$i] . '<br>'; > if ($i == count($addresses) - 1) > $form['recipient'] .= $addresses[$i]; > else > $form['recipient'] .= $addresses[$i] . ','; > } > echo 'Recipient = ' . $form['recipient'] . '<br>'; why are you exploding an array? $emails is already an array and can already be accessed via index i.e. $emails[0..n]; and similar to what adam metioned, i don't even know what would happen when you explode an array so your unexpected results are, well, expected. ;) $emails = array("[EMAIL PROTECTED]","[EMAIL PROTECTED]",[EMAIL PROTECTED]); $emails_cnt = count($addresses); for ($i = 0; $i < $emails_cnt; $i++) { echo "$i:{$emails[$i]}<br>"; if ($i == ($emails_cnt - 1)) { $form['recipient'] .= $emails[$i]; } else { $form['recipient'] .= $emails[$i] . ','; } } echo "Recipient = {$form['recipient']}<br>"; maybe that will work? (untested) chris. p.s. from now on don't use the count() function within loops (including the loop declaration) because it slows things way down (when you count the same variable over and over). instead do like what i did, count it ahead of time and then just reference the answer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php