这段代码:
function atest(){
$test = array(
"StartDate" => "08/01/2013",
"StartTime" =>"08:00:00",
"DepartmentID" => "75275",
"# Contacts Offered" => "3",
"# Contacts Handled" => "4",
"Average Talk Time" => "491.250000",
"Average Delay" => "5.666667",
"Percent SLA" => "1.333333");
$formatted = sprintf("%s %s TCSDATA %d %d %d %01.2f 0 %01.2f %01.2f 0\r\n",
$test["StartDate"],
$test["StartTime"],
$test['DepartmentID'],
$test['# Contacts Offered'],
$test['# Contacts Handled'],
$test['Average Talk Time'],
$test['Average Delay'],
$test['Percent SLA']
);
echo('<pre>');
echo( var_dump($test) );
echo('</pre>');
echo $formatted;
}
打印这个:
08/01/2013 08:00:00 TCSDATA 75275 ************************
但是,如果我修改sprintf格式以删除最后的0:
"%s %s TCSDATA %d %d %d %01.2f 0 %01.2f %01.2f \r\n"
我明白了:
08/01/2013 08:00:00 TCSDATA 75275 3 4 491.25 0 5.67 1.33
世界上有什么?
最佳答案 这个问题实际上是因为数字序列与Luhn算法匹配,并且在我的PCI环境中被掩盖了.我从测试中手动排除了文件,现在一切都按预期工作了.