<br>
<?php <br />
$file="铁血.torrent";<br>
$fp=fopen($file,"rb");<br>
$data=(readBt($fp));<br>
/**<br>
@author renlu xu <helloasp><br>
输出读入的数组。<br>
*/<br>
print_r($data);<br>
/**<br>
@function readbt 读入bt文件;<br>
@param $fp 文件指针<br>
@param $nowtype:当然的元数据类型<br>
@return Array 一个保存当前元数据集的数组<br>
*/<br>
function readBt($fp,$nowtype="DICT")<br>
{<br>
$nowindex="";<br>
while(!feof($fp))<br>
{<br>
$char=(string)fread($fp,1);<br>
/**<br>
其实仔细研究一下,可能这里几个case的摆放位置,比如哪个在前哪个在后,对速度都是有影响的,不过咱们暂时不管它<br>
*/<br>
switch($char)<br>
{<br>
case "1":<br>
case "2":<br>
case "3":<br>
case "4":<br>
case "5":<br>
case "6":<br>
case "7":<br>
case "8":<br>
case "9":<br>
case "0":<br>
{<br>
$nowindex.=$char;<br>
break;<br>
}<br>
case ":":<br>
{<br>
$nowtype="STRING";<br>
$string=fread($fp,intval($nowindex));<br>
<br>
$VARS[]=$string;<br>
$nowindex="";<br>
$nowtype="";<br>
break;<br>
}<br>
case "i":<br>
{<br>
<br>
$nowtype="NUMBER";<br>
break;<br>
<br>
}<br>
case "e":<br>
{<br>
/** <div class="clear">
</div></helloasp>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn