Skip to content

Latest commit

 

History

History
executable file
·
29 lines (19 loc) · 1.09 KB

readme.md

File metadata and controls

executable file
·
29 lines (19 loc) · 1.09 KB

Array to object

Latest Version on Packagist Software License Build Status Total Downloads

Gives you a global function that converts arrays to objects without removing object references. The object also implements Jsonable which will prettify the output if the object is returned (This only works in Laravel).

Installation

  1. composer require sempro/array-to-object

Usage

$data = [
    'id' => 1,
    'name' => 'Test',
];

$object = arrayToObject($data);

$object->name; // 'Test'

License

The MIT License (MIT). Please see License File for more information.