Adding replace and replaceRecursively methods
This commit is contained in:
25
readme.md
25
readme.md
@ -1,15 +1,22 @@
|
||||
Ary
|
||||
===
|
||||
|
||||
Are you tired from casting objects and arrays to each other or are bored using is `isset`? Don't do those anymore!
|
||||
Ary is a light class/function that makes accessing array items more convenient.
|
||||
Ary provides unified interface for ary/object. Really handy to store:
|
||||
|
||||
- arrays/objects those their items/properties varies conditionally.
|
||||
- storing registry, system configuration, env variables, etc.
|
||||
- when you perform a chain of action on an array/object
|
||||
|
||||
It's super cool and after a while you can not code in php without it.
|
||||
|
||||
Features
|
||||
---------
|
||||
1. You can access array items using `->` or `['']` syntax.
|
||||
2. You will get `null` if an index does not exists (instead of a nasty notification!)
|
||||
3. You can specify a default value for missing indexes.
|
||||
4. You can set/get a value within a deeply nested array using "dot" notation.
|
||||
5. A bunch of really handy methods: `merge`, `only`, `search`, `toObject`, ...
|
||||
6. (new) It extends `Illuminate\Support\Collection` class so all of its methods are available (https://laravel.com/docs/master/eloquent-collections)
|
||||
6. Now, `Ary` extends `Illuminate\Support\Collection` class so all of its methods are available (https://laravel.com/docs/master/eloquent-collections)
|
||||
|
||||
Examples
|
||||
--------
|
||||
@ -24,7 +31,7 @@ $ary = ary(2, 4, 6, 8); // or
|
||||
$ary = ary([2, 4, 6, 8]);
|
||||
$ary = ary(['x' => 'foo', 'y' => 'bar']);
|
||||
|
||||
//Assignment;
|
||||
//Assignment
|
||||
$ary->newItem=20; //or
|
||||
$ary['newItem']=20;
|
||||
|
||||
@ -34,7 +41,7 @@ $foo = $ary['x'];
|
||||
$missed = $ary->get('missed', 'Default value');
|
||||
$ary->all(); // returns the simple php array;
|
||||
|
||||
// behave similar to regular arrays
|
||||
// behaive as regular arrays
|
||||
count($ary); //returns 3
|
||||
unset($ary[0]);
|
||||
json_encode($ary);
|
||||
@ -48,14 +55,14 @@ $ary['production.table.weight']=200;
|
||||
|
||||
Installation
|
||||
============
|
||||
Simply, `include '__DIR__.'/src/helper.php';`
|
||||
Simply `include '__DIR__.'/src/helper.php';`
|
||||
|
||||
or using Composer:
|
||||
or use Composer:
|
||||
|
||||
composer require salarmehr/ary
|
||||
|
||||
* The class (`Ary()`) requires PHP 5.4 or newer.
|
||||
* The helper function (`ary()`) requires PHP 5.6 or newer.
|
||||
* The class (`Ary()`) requires PHP 5.4 or above.
|
||||
* The helper function (`ary()`) requires PHP 5.6 or above.
|
||||
|
||||
Licence
|
||||
=======
|
||||
|
Reference in New Issue
Block a user