PHP code example of navindex / simple-config

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

    

navindex / simple-config example snippets


use Navindex\SimpleConfig\Config;

$options = [
    'number of fingers' => 5,
    'allowed pets' => ['dog', 'cat', 'spider'],
    'cat' => [
        'name' => 'Mia',
        'food' => ['tuna', 'chicken', 'lamb'],
    ],
    'dog' => [
        'name' => 'Bless',
        'color' => [
            'body' => 'white',
            'tail' => 'black',
        ]
    ],
    'spider' => true,
    42,
    'some text'
];

$config = new Config($options);

$config
    ->set('spider', false)
    ->unset('dog.color.tail')
    ->append('cat.food', 'salmon')
    ->subtract('cat.food', 'tuna');

$spider = $config->get('spider');

$doWeHaveDog = $config->has('dog');

$arrConfig = $config->toArray();