Manage multidimensional arrays by reference

v1.0.0 2021-10-16 13:52 UTC

This package is auto-updated.

Last update: 2021-11-16 14:13:41 UTC


README

137578669-f6e199c6-3194-42d4-ad07-1b55ff1a20ec.png

Netonest Arr (array reference)

Netonest Arr is a tool for easy managing multidimensional arrays by reference.

Installation

Installation is via Composer

composer require netonest/arr

Usage

<?php

use Netonest\Arr\Arr;

$array = [
    'name'=> 'Netonest',
    'url' => 'http://localhost',
    'database' => [
        'db_host' => 'localhost',
        'db_user' => 'root',
        'db_pass' => '',
        'db_name' => 'Netonest'
    ],
    'logs' => []   
];

//Load the array
Arr::load($array);

//Get values
echo Arr::get('name'); //output is Netonest
echo Arr::get('database.db_host'); //output is localhost

//Get all values
print_r(Arr::all());

//Add new values
Arr::put('timezone','UTC'); 

Arr::put('database.db_charset','utf-8');

Arr::push('logs','Log message 1');
Arr::push('logs','Log message 2');

//Change values
Arr::put('name','My app name');

Arr::put('database.db_pass','1234');

//Remove values
Arr::forget('url');

Arr::forget('database.db_host');

//Get and remove values
Arr::pull('name'); //Output is Netonest

//Remove all values
Arr::flush();

//Check values
Arr::has('name');

Arr::has('database.db_host');

License

Netonest Arr is open-sourced software licensed under the MIT license.