https://github.com/divineomega/array_undot
array_undot (the opposite of the array_dot helper function) expands a dot notation array into a full multi-dimensional array.
https://github.com/divineomega/array_undot
array array-dot array-undot dot-notation-array laravel
Last synced: 4 months ago
JSON representation
array_undot (the opposite of the array_dot helper function) expands a dot notation array into a full multi-dimensional array.
- Host: GitHub
- URL: https://github.com/divineomega/array_undot
- Owner: DivineOmega
- License: lgpl-3.0
- Created: 2018-04-20T13:19:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T18:07:59.000Z (over 5 years ago)
- Last Synced: 2025-02-22T01:16:54.717Z (5 months ago)
- Topics: array, array-dot, array-undot, dot-notation-array, laravel
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 25
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# array_undot
[](https://travis-ci.org/DivineOmega/array_undot)
[](https://coveralls.io/github/DivineOmega/array_undot?branch=master)
[](https://styleci.io/repos/130364810)
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 divineomega/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.
```php
$dotNotationArray = ['products.desk.price' => 100];$expanded = array_undot($dotNotationArray)
// ['products' => ['desk' => ['price' => 100]]];
``````php
$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'
]
]
]
*/```