Skip to content

kjohnson/format-object-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format Object List

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' ] ]

About

Formats an associative array into a JS parsable array of objects.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages