nabeghe / arrayer
An array helper for PHP. It includes some useful methods and possibly other features.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nabeghe/arrayer
Requires
- php: >=7.4
- ext-json: *
- nabeghe/cally: *
- nabeghe/stringer: *
Requires (Dev)
- phpunit/phpunit: 9.6
This package is auto-updated.
Last update: 2025-10-02 20:00:44 UTC
README
An array helper for PHP. It includes some useful methods and possibly other features.
Some of the methods from the Arr class of the Laravel framework are also included in this library; however, some of them have been modified.
🫡 Usage
🚀 Installation
You can install the package via composer:
composer require nabeghe/arrayer
Arr Class
The main class that includes the useful methods is Nabegh\Arrayer\Arr.
Example:
use Nabeghe\Arrayer\Arrayer; $data1 = ['key_1' => 'value_1', 'key_3' => ['key_3_1' => 'value_3_1']]; $data2 = ['key_2' => 'value_2']; $data3 = ['key_3' => ['key_3_2' => 'value_3_2']]; $arrayer = new Arrayer(); print_r($arrayer->merge($data1, $data2, $data3)->data); /* Array ( [key_1] => value_1 [key_3] => Array ( [key_3_1] => value_3_1 [key_3_2] => value_3_2 ) [key_2] => value_2 ) */
Arrayer Class
Accepts any value, converts it to an array via Arr::cast, stores it, and returns it via data property.
It is possible to access the methods of the Arr class through the Arrayer object as well, with the difference that the main array parameter is no longer present.
Additionally, the ArrayAccess and JsonSerializable interfaces have also been implemented on Arrayer class.
📖 License
Licensed under the MIT license, see LICENSE.md for details.