本文介绍了适用于PHP的磁铁链接库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的人是否知道 磁体URI -解析器对于PHP?进行验证,还是从中提取一些信息?

Does anyone here know of a magnet-URI-parser for PHP? To validate it, or maybe to extract some information from it?

推荐答案

如果只需要这些字段,那么这里是一个快速而肮脏的班轮:

If you only need the fields, here is a quick and dirty one liner:

$link = 'magnet:?xt=urn:btih:0eb69459a28b08400c5f05bad3e63235b9853021&dn=Splinter.Cell.Blacklist-RELOADED&tr=udp%3A%2F%2Ftracker.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Fopen.demonii.com%3A1337';

parse_str(str_replace('tr=','tr[]=',parse_url($link,PHP_URL_QUERY)),$query);

print_r($query);

应该产生:

 Array
 (
    [xt] => urn:btih:0eb69459a28b08400c5f05bad3e63235b9853021
    [dn] => Splinter.Cell.Blacklist-RELOADED
    [tr] => Array
        (
            [0] => udp://tracker.com:80
            [1] => udp://tracker.publicbt.com:80
            [2] => udp://tracker.istole.it:6969
            [3] => udp://tracker.ccc.de:80
            [4] => udp://open.demonii.com:1337
        )
)

这篇关于适用于PHP的磁铁链接库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 08:48