All Projects → marcmascarell → arrayer

marcmascarell / arrayer

Licence: MIT license
Array manipulation. Get, set & delete keys with dot notation, also prepares an array to be put in a file (php array or json).

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to arrayer

dot-wild
Use powerful dot notation (dot path + wildcard) to manipulate properties of JSON
Stars: ✭ 28 (+100%)
Mutual labels:  dot-notation
mongo-dot-notation
Transform objects to MongoDB update instructions
Stars: ✭ 35 (+150%)
Mutual labels:  dot-notation
fastremap
Remap, mask, renumber, unique, and in-place transposition of 3D labeled images. Point cloud too.
Stars: ✭ 29 (+107.14%)
Mutual labels:  array-manipulations
performant-array-to-tree
Converts an array of items with ids and parent ids to a nested tree in a performant O(n) way. Runs in browsers and Node.js.
Stars: ✭ 193 (+1278.57%)
Mutual labels:  array-manipulations
yamlpath
Command-line get/set/merge/validate/scan/convert/diff processors for YAML/JSON/Compatible data using powerful, intuitive, command-line friendly syntax.
Stars: ✭ 78 (+457.14%)
Mutual labels:  dot-notation
has-value
Returns true if a value exists, false if empty. Works with deeply nested values using object paths.
Stars: ✭ 27 (+92.86%)
Mutual labels:  dot-notation
stringify-keys
Build an array of key paths from an object.
Stars: ✭ 18 (+28.57%)
Mutual labels:  dot-notation
pfinal-array
👍PHP数组操作增强组件.主要是对数组等数据进行处理
Stars: ✭ 52 (+271.43%)
Mutual labels:  php-array
get
🚚 A really small and type-safe (requires TypeScript >= 4.1.3) function, that gets a nested value from an object using a path string (like "a.b[0].d"). If value is 'undefined' or unreachable returns the placeholder instead.
Stars: ✭ 13 (-7.14%)
Mutual labels:  dot-notation
glob-object
Filter an object using glob patterns and dot notation.
Stars: ✭ 25 (+78.57%)
Mutual labels:  dot-notation
array undot
array_undot (the opposite of the array_dot helper function) expands a dot notation array into a full multi-dimensional array.
Stars: ✭ 15 (+7.14%)
Mutual labels:  dot-notation
expand-hash
Recursively expands property keys with dot-notation into objects.
Stars: ✭ 25 (+78.57%)
Mutual labels:  dot-notation
rxjs-ninja
RxJS Operators for handling Observable strings, numbers, booleans and more
Stars: ✭ 68 (+385.71%)
Mutual labels:  array-manipulations
underwater
~2kb - ES6 Collection of helper functions. Lodash like
Stars: ✭ 18 (+28.57%)
Mutual labels:  array-manipulations
array
Pack of advanced PHP array functions
Stars: ✭ 45 (+221.43%)
Mutual labels:  array-manipulations
php-helpers
A Collection of useful php helper functions.
Stars: ✭ 26 (+85.71%)
Mutual labels:  array-manipulations

Arrayer

Packagist Travis license

Array manipulation. Get, set & delete keys with dot notation, also prepares an array to be put in a file (php array or json).

Installation

Require this package in your composer.json and run composer update:

composer require mascame/arrayer

Usage

$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

Build a prepared output for file (This example uses Laravel's "File" class to put file contents):

/**
*   Available options for ArrayBuilder
*    [
*        'oldSyntax' => false, // use old array syntax
*        'minify' => false,
*        'indexes' => true, // Show the incremental indexes (array keys)
*        'startWithScript' => true, // start with <?php
*        '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());

Changelog

3.4

  • Fix missing files after migration to PSR-4

3.3

  • ArrayBuilder 'indexes' option to remove the incremental indexes (array keys)

3.1

  • Simplification
  • Improved builders

3.0

  • Simplified code
  • Improved ArrayBuilder, added options and included JsonBuilder
  • Removed ->append() method @ Arrayer because was a bit confusing
  • Removed not used laravel specific files

2.1

  • Added tests
  • Fixed arrayDot not being created on constructor
  • Removed unnecessary dependency

2.0

  • Added manipulation methods (get, set, delete)
  • Dot notation
  • Extracted builder

1.1

  • Added escaping for keys and values

Contributing

Thank you for considering contributing! You can contribute at any time forking the project and making a pull request.

Support

If you need help or any kind of support, please send an e-mail to Marc Mascarell at [email protected].

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].