donatj/php-ini-builder

PHP `parse_ini_string` Compatible INI Builder

v0.1.3 2014-08-11 21:09 UTC

README

Latest Stable Version License Build Status Scrutinizer Code Quality

Create PHP parse_ini_string / parse_ini_file compatible INI strings from associative arrays.

Requirements

  • php: >=5.3.0

Installing

Install the latest version with:

composer require 'donatj/php-ini-builder'

Example

Here is a simple example script:

<?php

require(__DIR__ . '/../vendor/autoload.php');

$data = array(
	'Title' => array(
		'str' => 'awesome',
		'int' => 7,
		'flt' => 10.2,
	),
	'Title 2' => array(
		'bool' => true,
		'arr' => array(
			'a', 'b', 'c', 6 => 'd', 'e', 'key' => 'f'
		)
	)
);

$x = new \donatj\Ini\Builder();
echo $x->generate($data);

Which outputs:

[Title]
str = 'awesome'
int = 7
flt = 10.2

[Title 2]
bool = true
arr[] = 'a'
arr[] = 'b'
arr[] = 'c'
arr[6] = 'd'
arr[] = 'e'
arr[key] = 'f'

Documentation

See: DOCS.md