Home > Backend Development > PHP Tutorial > foreach 输出显示、进度问题,高手解决。

foreach 输出显示、进度问题,高手解决。

WBOY
Release: 2016-06-23 13:36:29
Original
1180 people have browsed it


$citycode = array("北京"=>"101010100",
"青县"=>"101090702",
"磁县"=>"101091007",
"嘉义"=>"101340901",
"阿里山"=>"101340902",
"玉山"=>"101340903",
"新港"=>"101340904"
);
foreach ($citycode as $key=>$value ) {

echo '输出'.$value.'
';

}
?>


我要输出数组,但数组可能非常多(我要用数组做些生成的工作),我想数组一条一条,或者5条5条慢慢显示。因为不这样的话,我要等很久才看到执行结果,看不到执行进度。


回复讨论(解决方案)

在最前面加上下面语句
ob_start(); //打开输出缓冲区
ob_end_flush();
ob_implicit_flush(1); //立即输出
可以立即输出你的输出内容

效果明显。感谢大师指点。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template