2017 © Pedro Peláez
 

library object_to_array

This PHP package provides an `object_to_array` helper function.

image

divineomega/object_to_array

This PHP package provides an `object_to_array` helper function.

  • Tuesday, February 13, 2018
  • by DivineOmega
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

object_to_array helper function

Build Status Coverage Status StyleCI, (*1)

This PHP package provides an object_to_array helper function. You can use this function to convert an object to an array., (*2)

Installation

The object_to_array package can be easily installed using Composer. Just run the following command from the root of your project., (*3)

composer require "divineomega/object_to_array"

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started., (*4)

Usage

Here are a few examples of how to use the object_to_array helper function., (*5)

// Basic object

$object = new stdClass;
$object->name = 'John';
$object->age = 32;

$array = object_to_array($object)

/*
$array = [
    'name' => 'John',
    'age' => 32
];
*/
// Object with nested object

$object = new stdClass;
$object->name = 'John';
$object->age = 32;
$object->pet = new stdClass;
$object->pet->type = 'cat';
$object->pet->name = 'Mr Fluffkins The Third';

$array = object_to_array($object)

/*
$array = [
    'name' => 'John',
    'age' => 32,
    'pet' => [
        'name' => 'Mr Fluffkins The Third',
        'type' => 'cat'
    ]
];
*/
// Object with nested array

$object = new stdClass;
$object->name = 'John';
$object->age = 32;
$object->favouriteFoods = [
    'pizza',
    'cake'
];

$array = object_to_array($object)

/*
$array = [
    'name' => 'John',
    'age' => 32,
    'favouriteFoods' => [
        'pizza',
        'cake'
    ]
];
*/

The Versions

13/02 2018

dev-master

9999999-dev

This PHP package provides an `object_to_array` helper function.

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

13/02 2018

dev-analysis-qJ9b1E

dev-analysis-qJ9b1E

This PHP package provides an `object_to_array` helper function.

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall

12/02 2018

v1.0.0

1.0.0.0

This PHP package provides an `object_to_array` helper function.

  Sources   Download

LGPL-3.0-only

The Development Requires

by Jordan Hall