我想将此表添加到电子邮件中:
foreach ($songs as $key => $value) {
echo "<tr><td>" . ucfirst($key) . "</td><td>" . $value . "</td></tr>";
}
Run Code Online (Sandbox Code Playgroud)
但像这样将无法工作:
$message = '
<html>
<head>
</head>
<body>
<p>Hi, ' . ucfirst($name) . '<br>
</p>
<p>Heres the table</p>
<table class="tables">' .
foreach ($songs as $key => $value) {
echo "<tr><td>" . ucfirst($key) . "</td><td>" . $value . "</td></tr>";
}
. '
</table>
</body>
</html>
';
Run Code Online (Sandbox Code Playgroud)
提前致谢!:)
问题是你回应而不是追加.
$message = '
<html>
<head>
</head>
<body>
<p>Hi, ' . ucfirst($name) . '<br>
</p>
<p>Heres the table</p>
<table class="tables">';
foreach ($songs as $key => $value) {
$message .= "<tr><td>" . ucfirst($key) . "</td><td>" . $value . "</td></tr>";
}
$message .= '</table>
</body>
</html>
';
Run Code Online (Sandbox Code Playgroud)