我正在尝试通过邮件发送数组的内容,我尝试了 print_r 方法但是不太喜欢它在电子邮件中的格式,所以我尝试了内爆,但是目前它实际上并没有发送内容,而是只是“阵列阵列”
这是我的代码:
<?php
$con = mysqli_connect("localhost", "user","pw", "db");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$recipient_email = "email@email.com";
$result= mysqli_query($con, "SELECT * FROM subscribers WHERE datetime_registered >= DATE_SUB(NOW(), INTERVAL 9 DAY)")or die(mysqli_error($con));
$subscribers = array();
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$subscribers[] = array(
"uid" => $row['id'],
"name" => $row['name'],
"email" => $row['email'],
"ip" => $row['ip'],
"date_registered" => $row['datetime_registered']
);
}
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From: '.$recipient_email.''."\n";
$subject = "Subject";
$recipient = $recipient_email;
$content = implode("\n", $subscribers);
mail($recipient, $subject, $content, $headers);
?>
有谁知道出了什么问题?