timmah1 Posted November 12, 2008 Share Posted November 12, 2008 I'm setting up a newsletter system. I have a form that selects everybody from the database and puts the users email address into a hidden field like so <input type="hidden" name="user[]" value="<?=$row['email']; ?>" /> I'm testing to make sure it has all of the emails, when I click on the 'Submit' button, it should display every email that the newsletter is going to get sent to for testing purposes. What happens is, it displaying every email 13 different times. There are 128 different emails in the system, so logically it should only show 128 emails, but instead it's showing me 1,664 emails. Here is the code: $subscriber=$_POST['user']; $together = implode(", ", $subscriber); for($i = 0; $i < count($subscriber); $i++){ echo "$together<br>"; } Can anybody tell me why it's showing every email multiple times, and not just once? Thanks in advance I Link to comment https://forums.phpfreaks.com/topic/132447-solved-implode-function/ Share on other sites More sharing options...
GingerRobot Posted November 12, 2008 Share Posted November 12, 2008 You're imploding the data, which creates (in this case) a comma delimited string containing all of the values in the array. You then loop through the array echoing the string each time. You should either be looping or imploding. Not both. Link to comment https://forums.phpfreaks.com/topic/132447-solved-implode-function/#findComment-688608 Share on other sites More sharing options...
timmah1 Posted November 12, 2008 Author Share Posted November 12, 2008 I see now So the correct coding would be $together = implode(", ", $subscriber); echo "$together<br>"; Link to comment https://forums.phpfreaks.com/topic/132447-solved-implode-function/#findComment-688609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.