donatj/php-ini-builder

PHP `parse_ini_string` Compatible INI Builder

v0.3.0 2024-03-04 05:10 UTC

This package is auto-updated.

Last update: 2024-04-04 05:24:28 UTC


README

Latest Stable Version License ci.yml

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

Requirements

  • php: >=7.1
  • ext-ctype: *

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 = [
	'Title'   => [
		'str' => 'awesome',
		'int' => 7,
		'flt' => 10.2,
	],
	'Title 2' => [
		'bool' => true,
		'arr'  => [
			'a', 'b', 'c', 6 => 'd', 'e', 'key' => 'f',
		],
	],
];

$builder = new \donatj\Ini\Builder;

echo $builder->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