Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T18:07:59.000Z (almost 5 years ago)
- Last Synced: 2024-10-15T02:37:22.511Z (3 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
[![Build Status](https://travis-ci.org/DivineOmega/array_undot.svg?branch=master)](https://travis-ci.org/DivineOmega/array_undot)
[![Coverage Status](https://coveralls.io/repos/github/DivineOmega/array_undot/badge.svg?branch=master)](https://coveralls.io/github/DivineOmega/array_undot?branch=master)
[![StyleCI](https://styleci.io/repos/130364810/shield?branch=master)](https://styleci.io/repos/130364810)
![Packagist](https://img.shields.io/packagist/dt/DivineOmega/array_undot.svg)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'
]
]
]
*/```