PHP code example of austinhyde / iniparser

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

    

austinhyde / iniparser example snippets


array(
    'key' => 'value',
    'another_key' => 'another value',
    'section_name' => array(
        'a_sub_key' => 'yet another value'
    )
)

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

array(
    'boss' => array(
        'name' => 'John',
        'age' => 42
    ),
    'staff' => array(
        array (
            'name' => 'Mark',
            'age' => 35,
        ),
        array (
            'name' => 'Bill',
            'age' => 44,
        ),
    ),
)

array (
    'person' => array (
        'age' => 42,
        'name' => array (
            'first' => 'John',
            'last' => 'Doe'
        )
    )
)

array(
    'parent' => array(
        'arr' => array('a','b','c'),
        'val' => 'foo'
    ),
    'child' => array(
        'arr' => array('a','b','c','x','y','z'),
        'val' => 'foobar'
    )
)

array (
    'foo' => 'bar',
    'sect' => array (
        'foo' => 'bar'
    )
)

echo $config->production->database->connection; // output: mysql:host=127.0.0.1
echo $config->staging->debug; // output: 1