PHP code example of mascame / arrayer
1. Go to this page and download the library: Download mascame/arrayer 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/ */
mascame / arrayer example snippets
$array = array(
'this' => array(
'is' => 'an',
'example'
),
'we use a' => 'normal array',
'and manipulate it' => array(
'as' => array(
'we' => array(
'want' => ':D'
)
)
),
'thats it',
'cool? :)'
);
$arrayer = new \Mascame\Arrayer\Arrayer($array);
$arrayer->set('we.use.dot.notation', array('so', 'cool.'));
$arrayer->set('this.is', 'we gonna delete this very soon...');
$arrayer->delete('this.is');
$arrayer->set('more.examples', 'test');
$arrayer->get('more.examples'); // returns 'test'
$arrayer->getArray(); // returns the modified array
/**
* Available options for ArrayBuilder
* [
* 'oldSyntax' => false, // use old array syntax
* 'minify' => false,
* 'indexes' => true, // Show the incremental indexes (array keys)
* 'startWithScript' => true, // start with
* 'initialStatement' => 'return ',
* ]
*/
$builder = new \Mascame\Arrayer\Builder\ArrayBuilder($arrayer->getArray(), $options);
File::put('test.php', $builder->getContent()); // getContent returns a prepared output to put in a file
/**
* Available options for JsonBuilder
* [
* 'minify' => false,
* ]
*/
$builder = new \Mascame\Arrayer\Builder\JsonBuilder($arrayer->getArray(), $options);
File::put('test.json', $builder->getContent());