sempro/array-to-object

Convert an array to an object

1.0.0 2017-11-03 07:38 UTC

This package is auto-updated.

Last update: 2021-01-15 14:49:02 UTC


README

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.