我有一个数组
Array ( [0] => [email protected] [1] => [email protected] [2] => [email protected] [3] => [email protected] [4] => [email protected] [5] => [email protected] [6] => [email protected] [7] => [email protected] )
我已将其转换为字符串
echo implode("<br/>",$emails);
但是如何将每个 email_id 插入到 td 标签中
所以它看起来像这样
SNo. Email
1. [email protected]
2. [email protected]
3. [email protected]
不使用js可以吗
如果您有一个数组,请遍历该数组并将所需的数组部分存储在循环外的变量中。
$arr = ['[email protected]', '[email protected]'];
$html = '
<tr>
<td><strong>SNo.</strong></td>
<td><strong>Email</strong></td>
</tr>
';
if (count($arr) > 0) {
$arrLength = count($arr);
for ($i = 0; $i < $arrLength; $i++) {
$html .= '
<tr>
<td>' . ($i+1) . '</td>
<td>' . $arr[$i] . '</td>
</tr>
';
}
}
echo $html;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句