djeux/array-export

Export array as a formatted string, safe to save as a file

dev-master 2020-06-19 17:35 UTC

This package is auto-updated.

Last update: 2024-04-30 00:42:12 UTC


README

Export an array as a string that can be later saved as a file with proper formatting.

As a replacement for var_export, supports defining custom indentation size and character.

Usage:

<?php

use Djeux\ArrayExport\Export;

$array = [
    'one' => 'String',
    'two' => 'String',
];

$asString = Export::make()->export($array);
/**
[
    'one' => 'String',
    'two' => 'String',
]
*/

$asFile = Export::make()->asFile($array);
/**
<?php
return [
    'one' => 'String',
    'two' => 'String',
];
*/