I have the following code:
<?php
include('settings.php'); //Here I have my connection string
$result = mysql_query("SELECT myrow FROM mytable");
$storeArray = Array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$storeArray[] = $row['myrow'];
}
print_r($storeArray);
?>
And the results look like this: Array ( [0] => emailaddress1@email.com [1] => [2] => emailaddress2@email.com [3] => emailaddress3@email.com )
I was wondering what I need to do in order for it to print like this:
emailaddress1@email.com, emailaddress2@email.com, emailaddress3@email.com ..and so forth.
The reason is I've been tasked with creating mailing list, so I need to print out all of the email addresses in the database in an easy-to-insert into Outlook format
Is there a better way?
implode
( ', ', $storeArray)
Or try this method :
foreach($storeArray as $value)
$stringval.= $value.', ';
$finalval = substr($stringval,0,-2);
echo $finalval;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.