kjohnson / format-object-list
将关联数组格式化为可由JS解析的对象数组。
0.1.0
2021-01-18 22:22 UTC
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-09-25 23:35:00 UTC
README
将关联数组格式化为可由JS解析的标签/值对象数组。
安装
composer require kjohnson/format-object-list
用法
$data = [ 'foo' => 'bar' ]; $formatter = FormatObjectList\Factory::fromKeyValue( $data ); $list = $formatter->format(); // [ [ 'label' => 'bar', 'value' => 'foo' ] ]
$data = [ 'foo' => 'bar' ]; $formatter = FormatObjectList\Factory::fromValueKey( $data ); $list = $formatter->format(); // [ [ 'label' => 'foo', 'value' => 'bar' ] ]