php继续在最后一个元素时继续重复启动



我有代码带来客户端的实时TS文件

我有包括动态文件的文件夹

/files
1_0.ts
1_1.ts
1_2.ts

我的代码通过该代码将文件带到客户端

$files = "";
    $files = glob('/files/1_*.ts');
    foreach ($files as $file) {
    readfile($file);
}

代码获取所有文件并将其发送给客户端,一切都可以

我需要该客户每次到达最后一个元素时继续读取文件,直到他关闭浏览器

更多解释

client get
1_0.ts
1_1.ts
1_2.ts
and watch them , I need client to read them again when he at the last file
1_0.ts
1_1.ts
1_2.ts
1_0.ts
1_1.ts
1_2.ts
1_0.ts
1_1.ts
1_2.ts
etc ..... until client close by itself

您可以使用以下内容:

while (!connection_aborted()) {
    // here goes Your code that reads the files
    foreach (glob('/files/1_*.ts') as $file)
        readfile($file);
    // some waiting may be useful here?
    sleep(1);
}

相关内容

最新更新