我想通過郵件發送一個數組的內容,我已經嘗試了print_r方法,但是並不真正喜歡它在郵件中格式化的方式,所以我嘗試了內爆,但是目前它沒有實際發送的內容,而只是「陣列陣列陣列」PHP發送數組與郵件()
這是我的代碼:
<?php
$con = mysqli_connect("localhost", "user","pw", "db");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
$recipient_email = "[email protected]";
$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);
?>
有誰知道是怎麼回事了?
菲爾這是偉大的感謝,但它實際上並沒有把它放在一個新行,我怎麼才能到每個用戶的之間的新線電子郵件? – Jamie000012
用'「
」'替換'「\ n」'。我已更新我的代碼 –
謝謝Phil Cross – Jamie000012