PHP code example of hedronium / key-array

1. Go to this page and download the library: Download hedronium/key-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/ */

    

hedronium / key-array example snippets


use Hedronium\KeyArray\KeyArray;

$arr = new KeyArray;

// or
$arr = KeyArray::array();

$arr[[]]              = 'The void in my heart.';
$arr[['a']]           = 'AYY';
$arr[['b']]           = 'BEE';
$arr[['a', 'b']]      = 'AYY-BEE';
$arr[['a', 'b', 'c']] = 'AYY-BEE-CEE';

foreach ($arr as $key => $val) {
	echo str_pad(implode(' -> ', $key), 20, ' ', STR_PAD_LEFT);
	echo ' = ';
	echo $val;
	echo PHP_EOL;
}

////// OUTPUT: /////////////////////////
//             = The void in my heart.
//           a = AYY
//      a -> b = AYY-BEE
// a -> b -> c = AYY-BEE-CEE
//           b = BEE