这就是你想要的。我已经转换为 sleep 1 而不是 usleep 以证明它有效,但如果你将它切换回来,它会完成你想要的。别客气。
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
for ($_x = 1; $_x < 11; $_x++) {
$_m = microtime_float();
$_v = sleep(1);
$_n = microtime_float();
do{
//script here
echo "<hr></br>".$_m."</br>".$_n ."</br>" .$_x;
}
while($_v);
}
输出
1396497686.9354 1396497687.9356 1
1396497687.9357 1396497688.9363 2
1396497688.9364 1396497689.937 3
1396497689.9371 1396497690.9381 4
1396497690.9381 1396497691.9392 5
1396497691.9393 1396497692.9398 6
1396497692.9399 1396497693.9406 7
1396497693.9406 1396497694.9415 8
1396497694.9415 1396497695.9424 9
1396497695.9424 1396497696.9427 10