小编use*_*165的帖子

解析.srt文件

1
00:00:00,074 --> 00:00:02,564
Previously on Breaking Bad...

2
00:00:02,663 --> 00:00:04,393
Words...
Run Code Online (Sandbox Code Playgroud)

我需要用php解析srt文件并用变量打印文件中的所有subs.

我找不到合适的reg exps.当这样做时,我需要采用id,时间和字幕变量.并且当打印时,不存在array()s等等必须与原始文件中的相同.

我的意思是我必须打印出来;

$number <br> (e.g. 1)
$time <br> (e.g. 00:00:00,074 --> 00:00:02,564)
$subtitle <br> (e.g. Previously on Breaking Bad...)
Run Code Online (Sandbox Code Playgroud)

顺便说一句,我有这个代码.但它没有看到线条.它必须编辑,但如何?

$srt_file = file('test.srt',FILE_IGNORE_NEW_LINES);
$regex = "/^(\d)+ ([\d]+:[\d]+:[\d]+,[\d]+) --> ([\d]+:[\d]+:[\d]+,[\d]+) (\w.+)/";

foreach($srt_file as $srt){

    preg_match($regex,$srt,$srt_lines);

    print_r($srt_lines);
    echo '<br />';

}
Run Code Online (Sandbox Code Playgroud)

php parsing srt

4
推荐指数
1
解决办法
7798
查看次数

使用Greasemonkey进行跨域帖子?

我需要在后台发布Greasemonkey.我试图动态创建一个iframe并发布到它,但它不起作用:

function crossDomainPost() {
    // Add the iframe with a unique name
    var iframe = document.createElement("iframe");
    var uniqueString = "CHANGE_THIS_TO_SOME_UNIQUE_STRING";
    document.body.appendChild(iframe);
    iframe.style.display = "none";
    iframe.contentWindow.name = uniqueString;

    // construct a form with hidden inputs, targeting the iframe
    var form = document.createElement("form");
    form.target = uniqueString;
    form.action = "http://INSERT_YOUR_URL_HERE";
    form.method = "POST";

    // repeat for each parameter
    var input = document.createElement("input");
    input.type = "hidden";
    input.name = "INSERT_YOUR_PARAMETER_NAME_HERE";
    input.value = "INSERT_YOUR_PARAMETER_VALUE_HERE";
    form.appendChild(input);

    document.body.appendChild(form);
    form.submit();
}
Run Code Online (Sandbox Code Playgroud)


有人说即使我们发帖,我们也无法接受这些价值观.如果我们不能,只需让用户访问该页面即可.它可以在JS,jQuery,AJAX帖子中.不仅仅是form-iframe技巧.

javascript post greasemonkey

0
推荐指数
1
解决办法
4464
查看次数

使用 php 获取 json youtube 建议

http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&cp=1&q=WORD&alt=json
Run Code Online (Sandbox Code Playgroud)

我有这个网址。它以 JSON 格式创建 youtube 自动完成建议。我必须用 php 阅读这个并用 html 打印。我不能那样做。

互联网上的所有 JSON 解码教程都不适用于 youtube JSON。

最后,我只想要一个简单的代码来读取数据并使用 PHP 以 HTML 格式打印。

php youtube json

-1
推荐指数
1
解决办法
1414
查看次数

标签 统计

php ×2

greasemonkey ×1

javascript ×1

json ×1

parsing ×1

post ×1

srt ×1

youtube ×1