Pack of advanced PHP array functions
Repo minwork/array, read from GitHub 9 h ago. minwork has not joined Take My Repo.
set method now also allow to supply object implementing ArrayAccess instead of pure array as first argument, as well as handling nested ArrayAccess objects.
Added new mode to check method that enables checking if only one of the array elements meet specified condition.
Also greatly improved check documentation - https://minwork.gitbook.io/array/validating-array/check
Added Arr::filter method which is a wrapper around array_filter to allow chaining in ArrObj
Added method to traverse through array or iterable object without modifying it.
More info in documentation: https://minwork.gitbook.io/array/traversing-array/iterating
Added method to find element(s) inside an array or iterable object.
More info in documentation: https://minwork.gitbook.io/array/manipulating-array/finding
ArrObj which can be used to easily chain Arr methods.ArrObj instance can be obtained by either explicitly calling it's constructor with new ArrObj(...) or for even easier chaining Arr::obj(...) method.
// Chain setting nested array values Arr::obj()->set('foo', 'bar')->set('test.[]', 'test')->getArray() -> [ 'foo' => 'bar', 'test' => ['test'] ] // Quickly flatten array of objects grouped by id Arr::obj([...])->groupObjects('getId')->flattenSingle()->getArray()
What's more, ArrObj contain PHPDoc for every method that can be used in it, so you can take advantage of your editor autocomplete feature.
Full documentation of this feature, coming soon.