PHP code example of tebru / multi-array

1. Go to this page and download the library: Download tebru/multi-array library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tebru / multi-array example snippets


$array = [
    'key' => 'value',
    'key2' => ['nested-key' => 'value2'],
];
$multiArray = new MultiArray($array);
$multiArray = $multiArrayFactory->make($array);

$json = json_encode($array);
$multiArray = new MultiArray($json);
$multiArray = $multiArrayFactory->make($json);

$multiArray->get('key2'); // returns ['nested-key' => 'value2']
$multiArray->get('key2.nested-key'); // returns 'value2'
$multiArray->get('key3'); // throws OutOfBoundsException

$multiArray = new MultiArray($array, ':');
$multiArray = $multiArrayFactory->make($array, '--');

isset($multiArray['key2.nested-key']);
$multiArray['key2.nested-key'];
$multiArray['key2.nested-key'] = 'value';
unset($multiArray['key2.nested-key']);