narrowspark / pretty-array
2.0.2
2019-08-13 09:00 UTC
Requires
- php: ^7.2
- symfony/polyfill-mbstring: ^1.8.0
Requires (Dev)
- narrowspark/coding-standard: ^1.2.1
- phpunit/phpunit: ^7.2.0
This package is auto-updated.
Last update: 2019-08-16 06:46:37 UTC
README
分支状态
安装
使用 Composer 安装此包
composer require narrowspark/pretty-array
使用方法
use Narrowspark\PrettyArray\PrettyArray; $prettyArray = new PrettyArray();
如果你只传递一个数组,你会得到以下输出。
/** * This is the output. * * [ * 0 => 1, * ] */ $prettyArray->print([1]);
要使数组输出从4个空格开始,只需更改缩进级别。
/** * This is the output. * * [ * 0 => 1, * ] */ $prettyArray->print([1], 2);
你可以添加一个类型解析器来更改值输出。
所有支持的类型可以在 php.net 上找到
$prettyArray->setResolver('object', function($value) { return 'foo' }); /** * This is the output. * * [ * 0 => 'foo', * ] */ $prettyArray->print( [ 0 => function() { return 'foo'; }, ], );
测试
你需要运行
$ php vendor/bin/phpunit
贡献
注意:请注意,此项目以贡献者行为准则发布。通过参与此项目,你同意遵守其条款。
致谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 以获取更多信息。