Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rapidwebltd/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/rapidwebltd/array_undot
array dot-notation helper-functions laravel php
Last synced: about 1 month 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/rapidwebltd/array_undot
- Owner: rapidwebltd
- License: lgpl-3.0
- Created: 2018-01-12T13:02:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-20T13:50:15.000Z (over 6 years ago)
- Last Synced: 2024-10-10T20:14:00.159Z (2 months ago)
- Topics: array, dot-notation, helper-functions, laravel, php
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 16
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
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 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.
```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'
]
]
]
*/```