PHP输出随机视频API代码

输出文本里面的远程视频链接代码如下

<?php
function read(...$filelist) {
    $list = [];
    foreach ($filelist as $file) {
        $handle = fopen($file, 'r');
        while (($line = fgets($handle)) !== false) {
            array_push($list, trim($line));
        }
        fclose($handle);
    }
    return $list;
}
$list = read('mp4.txt');
$url = $list[array_rand($list)];
header("Location: {$url}");

输出文件夹里面的本地视频代码如下

<?php $mp4_array = glob("mp4/*.{mp4}",GLOB_BRACE);
$mp4 = array_rand($mp4_array);
header("location:$mp4_array[$mp4]");
?>

有任何问题评论区留言

上一篇 PHP输出随机图片API代码
下一篇 随机输出通用接口代码
00 : 00 : 00
2026719星期日
左侧头像 中间图片 右侧头像
加载中...
最新评论
看透一切的大黄
看透一切的大黄
5月2日
做的真好,收藏了。
YBExistence
YBExistence
3月20日
重新添加一下 站名:轻淡时光 简述:爱与生活,皆在此处 链接:https://www.lybblog.cn 订阅:https://www.lybblog.cn/
评论于友情链接
xuan
xuan
2月10日
小年快乐~ ::bilibili:dianzan::
评论于留言板
wu先生
wu先生
2月5日
甜蜜日常,就是看不到图片了。
刘郎
刘郎
11月1日
咦 友链还没更新呢 难怪一直提示异常 特意过来看看 啥情况🫣
评论于友情链接