Array
Pack of advanced PHP array functions
Install / Use
/learn @minwork/ArrayREADME
Minwork Array
Pack of array convenience methods for handling:
- Nested arrays
- Arrays of objects
- Associative arrays
- Chaining array transformations
Easily create, access, validate, manipulate and transform arrays
Advanced implementation of well known operations:
Installation
composer require minwork/array
Advantages
- Thoroughly tested
- Well documented
- Leverages PHP 7 syntax and speed
- No external dependencies
- Large variety of usages
Example of usage
// Set nested array value
$array = Arr::set([], 'key1.key2.key3', 'my_value');
// Which is equivalent to
[
'key1' => [
'key2' => [
'key3' => 'my_value'
]
]
]
// Get nested array value
Arr::get($array, 'key1.key2') -> ['key3' => 'my_value']
// Check if array has nested element
Arr::has($array, 'key1.key2.key3') -> true
// Map array while accessing it's key
Arr::map($array, function ($key, $value) {
// Your code here
});
// Find array element
Arr::find($array, function ($element) {
return Arr::get($element, 'key2.key3') === 'my_value';
}) -> [ 'key2' => [ 'key3' => 'my_value'] ]
// Chain few methods
Arr::obj(['test' => 1, 'foo' => 'bar'])
->set('abc', 123)
->set('[]', 'auto_index')
->remove('foo')
->getArray()
->
[
'test' => 1,
'abc' => 123,
'auto_index'
]
// Group objects by the result of calling method 'getSize' on each object
Arr::groupObjects([$cat, $dog, $fish, ...], 'getSize') ->
[
'medium' => [$cat, $dog, ...],
'small' => [$fish, ...],
...
]
Documentation
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
