rych/bencode 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rych/bencode

最新稳定版本:v1.0.0

Composer 安装命令:

composer require rych/bencode

包简介

Bencode serializer for PHP 5.3+

README 文档

README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads

This library allows developers to encode or decode bencoded data strings in PHP 5.3+. More information about bencode can be found at Wikipedia. The format is primarily used in the .torrent file specification.

Install

Via Composer

$ composer require rych/bencode

Usage

Encoding an array

<?php

use Rych\Bencode\Bencode;

$data = array(
    "string" => "bar",
    "integer" => 42,
    "array" => array(
        "one",
        "two",
        "three",
    ),
);

echo Bencode::encode($data);

The above produces the string d5:arrayl3:one3:two5:threee7:integeri42e6:string3:bare.

Decoding a string

<?php

use Rych\Bencode\Bencode;

$string = "d5:arrayl3:one3:two5:threee7:integeri42e6:string3:bare";

print_r(Bencode::decode($string));

The above produces the the following output:

Array
(
    [array] => Array
        (
            [0] => one
            [1] => two
            [2] => three
        )

    [integer] => 42
    [string] => bar
)

Testing

$ vendor/bin/phpunit -c phpunit.dist.xml

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 21.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 31
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 1

GitHub 信息

  • Stars: 31
  • Watchers: 4
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-08-22