donatj / php-ini-builder
PHP `parse_ini_string` Compatible INI Builder
Fund package maintenance!
www.paypal.me/donatj/15
Ko Fi
donatj
Installs: 97 095
Dependents: 2
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=7.1
- ext-ctype: *
Requires (Dev)
- corpus/coding-standard: ^0.6.0
- donatj/drop: *
- friendsofphp/php-cs-fixer: ^3.1
- phpunit/phpunit: ~7|~9
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-04-04 05:24:28 UTC
README
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'