PHP code example of me-io / php-ini-parser

1. Go to this page and download the library: Download me-io/php-ini-parser 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/ */

    

me-io / php-ini-parser example snippets


[
    'key' => 'value',
    'another_key' => 'another value',
    'section_name' => [
        'a_sub_key' => 'yet another value'
    ]
]

[
    'environment' => 'testing',
    'testing' => [
        'debug' => '1',
        'database' => [
            'connection' => 'mysql:host=127.0.0.1',
            'name' => 'test',
            'username' => '',
            'password' => ''
        ],
        'secrets' => ['1','2','3']
    ],
    'staging' => [
        'debug' => '1',
        'database' => [
            'connection' => 'mysql:host=127.0.0.1',
            'name' => 'stage',
            'username' => 'staging',
            'password' => '12345'
        ],
       'secrets' => ['1','2','3']
    ],
    'production' => [
        'debug' => '',
        'database' => [
            'connection' => 'mysql:host=127.0.0.1',
            'name' => 'production',
            'username' => 'root',
            'password' => '12345'
        ],
        'secrets' => ['1','2','3']
    ]
]

[
    'boss' => [
        'name' => 'John',
        'age' => 42
    ],
    'staff' => [
        [
            'name' => 'Mark',
            'age' => 35,
        ],
        [
            'name' => 'Bill',
            'age' => 44,
        ],
    ],
]

[
    'person' => [
        'age' => 42,
        'name' => [
            'first' => 'John',
            'last' => 'Doe'
        ]
    ]
]

[
    'parent' => [
        'arr' => ['a','b','c'],
        'val' => 'foo'
    ],
    'child' => [
        'arr' => ['a','b','c','x','y','z'],
        'val' => 'foobar'
    ]
]

[
    'foo' => 'bar',
    'sect' => [
        'foo' => 'bar'
    ]
]

echo $config->production->database->connection; // output: mysql:host=127.0.0.1
echo $config->staging->debug; // output: 1
ini
$parser = new \Ini\Parser('sample.ini');
$config = $parser->parse();
ini
colors = [blue, green, red]