末印刷额外的数字我有一个PHP(诉7.0.16)脚本在命令行上运行:的printf在CLI PHP在行
$ct = 1;
foreach($sort_this as $cur_site_id => $dx){
$cur_location = $locations[$cur_site_id]['location'];
$msg = "\033[A\33[2K\r" . 'getting data for %25s (' . $cur_site_id . ') store: %7s %01.2f' . "\n";
echo printf($msg, $cur_location, ($ct . '/' . count($sort_this)), number_format((($ct/count($sort_this)) * 100), 2));
$ct++;
}
这个循环运行约40次迭代。 printf语句适用于1个小问题。在“获取数据”行后面的行中,我看到一个从7x-7y开始增加的数字(有时从71开始,有时在77等)。我无法弄清楚是什么导致这个数字被打印出来。因此,当循环开始我看到屏幕上的内容是这样的:
getting data for DENVER (531) store: 42/42 0.00
77
,并在完成时是这样的:
getting data for SEATTLE (784) store: 42/42 100.00
79
我发现如何打印在同一线路上,在这里清除数据:
Erase the current printed console line
有没有一种方法,以防止显示7X代码?另外,它们是什么?
不能相信我错过了。非常感谢! – raphael75