kjohnson / format-object-list
Formats an associative array into a JS parsable array of objects.
0.1.0
2021-01-18 22:22 UTC
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2026-02-26 03:10:38 UTC
README
Formats an associative array into a JS parsable array of label/value objects.
Installation
composer require kjohnson/format-object-list
Usage
$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' ] ]