Skip to content

array_undot (the opposite of the array_dot helper function) expands a dot notation array into a full multi-dimensional array.

License

Notifications You must be signed in to change notification settings

rapidwebltd/array_undot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

array_undot

Build Status Coverage Status StyleCI Packagist

This package provides a helper function called array_undot, which expands a dot notation array into a full multi-dimensional array. It is, therefore, the opposite of the array_dot helper function provided by Laravel.

Installation

To install, just run the following composer command.

composer require rapidwebltd/array_undot

The array_undot helper function will then be available globally in your project.

Usage

The following basic examples show how to use the array_undot helper function.

$dotNotationArray = ['products.desk.price' => 100];

$expanded = array_undot($dotNotationArray)

// ['products' => ['desk' => ['price' => 100]]];
$dotNotationArray = ['products.desk.price' => 100, 
                     'products.desk.name' => 'Oak Desk',
                     'products.lamp.price' => 15,
                     'products.lamp.name' => 'Red Lamp'];

$expanded = array_undot($dotNotationArray)

/*
[
    'products' => [
        'desk' => [
            'price' => 100,
            'name' => 'Oak Desk'
        ],
        'lamp' => [
            'price' => 15,
            'name' => 'Red Lamp'
        ]
    ]
]
*/

About

array_undot (the opposite of the array_dot helper function) expands a dot notation array into a full multi-dimensional array.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages