Jump to content

implode


dudejma

Recommended Posts

I keep getting the "Invalid arguments passed in..." error when trying to use implode. Here's the code:

 

$getPilots = "SELECT * FROM users WHERE emailOption = '1' AND status = '1'";
$runGetPilots = mysql_query($getPilots);
while ($info = mysql_fetch_array($runGetPilots)) {
$emails = $info['email'];
$to = implode(', ', $emails);

 

The ending bracket is there, i just didn't include it in the code. Any suggestions? Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/255488-implode/
Share on other sites

$emails holds the value of $info['email'], which is a string, implodes()'s second parameter requires an array. what you can do, if you want to implode only the emails field, is something like this.

 

$emails_arr = array();
while ($info = mysql_fetch_array($runGetPilots)) {
$emails_arr[] = $info['email'];
}
$to = implode(', ', $emails_arr);

Link to comment
https://forums.phpfreaks.com/topic/255488-implode/#findComment-1309908
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.