kjohnson / format-object-list
Formats an associative array into a JS parsable array of objects.
Installs: 172 542
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-10-25 23:38:46 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' ] ]