Skip to content

indentno/array-to-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.