Skip to content
Converts an array to an object with reference
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE.md
composer.json
phpunit.xml.dist
readme.md

readme.md

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.

You can’t perform that action at this time.