1. Go to this page and download the library: Download dschoenbauer/dot-notation 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/ */
dschoenbauer / dot-notation example snippets
use DSchoenbauer\DotNotation\ArrayDotNotation;
$mongoConnection = [
'mongo' => [
'default' => [ 'user' => 'username', 'password' => 's3cr3t' ]
]
];
$config = new ArrayDotNotation($mongoConnection);
--- or ---
$config = ArrayDotNotation::with($mongoConnection);
// Get plain value
$user = $config->get('mongo.default.user');
/*
$user = 'username';
*/
// Get array value
$mongoDefault = $config->get('mongo.default');
/*
$mongoDefault = ['user' => 'username', 'password' => 's3cr3t'];
*/