我已经打了几次,只是想知道是否有人可能知道为什么会发生这种情况。
我传递的数组来自 WHM/cPanel API,格式为 (var_dump()ed):
array (size=14)
'_diskquota' => string '262144000' (length=9)
'_diskused' => string '31459' (length=5)
'diskquota' => string '250' (length=3)
'diskused' => string '0.03' (length=4)
'diskusedpercent' => string '0' (length=1)
'diskusedpercent20' => string '0' (length=1)
'domain' => string 'xxxxxxx.co.uk' (length=20)
'email' => string 'info@xxxxxxx.co.uk' (length=25)
'humandiskquota' => string '250Â MB' (length=7)
'humandiskused' => string '30.72Â KB' (length=9)
'login' => string 'info@xxxxxxx.co.uk' (length=25)
'mtime' => string '1347964089' (length=10)
'txtdiskquota' => string '250' (length=3)
'user' => string 'info' (length=4)
我正在将其转换为具有以下功能的 HTML 表格:
public function formatEmailAccountsArrayToTable( $email_accounts ) {
$returnHTML = '';
$topentag = '<table class="email_accounts_table">';
$theader = '<thead><tr>
<th>Email</th><th>User</th><th>Domain</th><th>Disk Quota</th><th>Disk Used</th>
</tr></thead><tbody>';
$tclosetag = '</tbody></table>';
$returnHTML .= $topentag . $theader;
foreach( $email_accounts as $v ) {
$returnHTML .= '
<tr>
<td>' . $v['email'] . '</td>
<td>' . $v['user'] . '</td>
<td>' . $v['domain'] . '</td>
<td>' . $v['diskquota'] . '</td>
<td>' . $v['diskused'] . '</td>
</tr>';
}
$returnHTML .= $tclosetag;
return $returnHTML;
}
输出如下:
Email User Domain Disk Quota Disk Used
2 2 2 2 2
3 3 3 3 3
2 2 2 2 2
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
b b b b b
i i i i i
2 2 2 2 2
3 3 3 3 3
i i i i i
1 1 1 1 1
2 2 2 2 2
i i i i i
我看不出为什么任何值会被截断/转换为表中输出的值。
有谁知道为什么会发生这种情况,因为流程应该非常简单,但行为却很奇怪?