Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjohnson/format-object-list
Formats an associative array into a JS parsable array of objects.
https://github.com/kjohnson/format-object-list
Last synced: 20 days ago
JSON representation
Formats an associative array into a JS parsable array of objects.
- Host: GitHub
- URL: https://github.com/kjohnson/format-object-list
- Owner: kjohnson
- Created: 2021-01-18T22:17:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T15:12:57.000Z (over 3 years ago)
- Last Synced: 2024-09-17T17:27:24.726Z (about 2 months ago)
- Language: PHP
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Format Object List
Formats an associative array into a JS parsable array of label/value objects.
## Installation
`composer require kjohnson/format-object-list`
## Usage```php
$data = [ 'foo' => 'bar' ];
$formatter = FormatObjectList\Factory::fromKeyValue( $data );
$list = $formatter->format();
// [ [ 'label' => 'bar', 'value' => 'foo' ] ]
``````php
$data = [ 'foo' => 'bar' ];
$formatter = FormatObjectList\Factory::fromValueKey( $data );
$list = $formatter->format();
// [ [ 'label' => 'foo', 'value' => 'bar' ] ]
```