PHPackages                             concept-labs/arrays - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. concept-labs/arrays

ActiveLibrary[API Development](/categories/api)

concept-labs/arrays
===================

(C)oncept-Labs Arrays API

1.1.2(7mo ago)0382MITPHPPHP &gt;=8.0

Since Jul 15Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/Concept-Labs/arrays)[ Packagist](https://packagist.org/packages/concept-labs/arrays)[ RSS](/packages/concept-labs-arrays/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (10)Used By (2)

Concept-Labs Arrays
===================

[](#concept-labs-arrays)

A powerful PHP library for working with arrays using dot notation, recursive operations, and advanced querying capabilities.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/f32695bd6f65b12545162e869707d33dac6bcb5f6e5dc0d48b6d1f8162b6c247/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d626c75652e737667)](https://www.php.net/)

Overview
--------

[](#overview)

The **Concept-Labs Arrays** library provides a comprehensive suite of tools for manipulating and querying deeply nested PHP arrays. It offers three main components:

- **DotArray**: Object-oriented wrapper for array manipulation using dot notation
- **RecursiveDotApi**: Static API for recursive array operations with dot notation
- **RecursiveApi**: Static API for basic recursive array operations

Features
--------

[](#features)

- 🎯 **Dot Notation Access**: Access and manipulate deeply nested arrays using simple dot paths (`user.profile.name`)
- 🔄 **Recursive Operations**: Map, filter, reduce, and transform arrays at any depth
- 🔍 **Advanced Querying**: Query arrays with wildcard patterns and column filtering
- 🛠️ **Rich Mutation API**: Push, pop, increment, merge, replace, fill and more
- 📦 **Array/Object Access**: Use both array syntax (`$arr['key']`) and object syntax (`$arr->key`)
- 🔗 **Standard Interfaces**: Implements `ArrayAccess`, `IteratorAggregate`, `JsonSerializable`
- ⚡ **Performant**: Optimized for both reference and copy operations

Installation
------------

[](#installation)

Install via Composer:

```
composer require concept-labs/arrays
```

### Requirements

[](#requirements)

- PHP 8.0 or higher

For detailed installation instructions, see the [Installation Guide](docs/Installation.md).

Quick Start
-----------

[](#quick-start)

### DotArray - Object-Oriented API

[](#dotarray---object-oriented-api)

```
use Concept\Arrays\DotArray\DotArray;

// Create from array
$config = new DotArray([
    'app' => [
        'name' => 'MyApp',
        'version' => '1.0.0',
        'settings' => [
            'debug' => true,
            'timezone' => 'UTC'
        ]
    ]
]);

// Get values using dot notation
echo $config->get('app.name');              // "MyApp"
echo $config->get('app.settings.debug');    // true

// Set values
$config->set('app.settings.locale', 'en');

// Array access syntax
echo $config['app.version'];                // "1.0.0"
$config['app.settings.cache'] = true;

// Object access syntax
echo $config->app->get('name');             // "MyApp"

// Check existence
if ($config->has('app.settings.debug')) {
    // ...
}

// Remove values
$config->unset('app.settings.debug');
```

### RecursiveDotApi - Static API with Dot Notation

[](#recursivedotapi---static-api-with-dot-notation)

```
use Concept\Arrays\RecursiveDotApi;

$data = [
    'users' => [
        'admin' => ['name' => 'John', 'role' => 'admin'],
        'guest' => ['name' => 'Jane', 'role' => 'user']
    ]
];

// Get nested value
$name = RecursiveDotApi::get($data, 'users.admin.name'); // "John"

// Set nested value
RecursiveDotApi::set($data, 'users.admin.email', 'john@example.com');

// Check existence
$exists = RecursiveDotApi::has($data, 'users.admin.role'); // true

// Flatten to dot notation
$flat = RecursiveDotApi::flatten($data);
// ['users.admin.name' => 'John', 'users.admin.role' => 'admin', ...]

// Unflatten back to nested
$nested = RecursiveDotApi::unflatten($flat);
```

### RecursiveApi - Basic Recursive Operations

[](#recursiveapi---basic-recursive-operations)

```
use Concept\Arrays\RecursiveApi;

$data = [
    'products' => [
        ['name' => 'Laptop', 'price' => 999],
        ['name' => 'Mouse', 'price' => 25]
    ]
];

// Map all values
$mapped = RecursiveApi::map($data, fn($value) =>
    is_numeric($value) ? $value * 1.1 : $value
);

// Filter values
$filtered = RecursiveApi::filter($data, fn($value) =>
    !is_numeric($value) || $value > 50
);

// Reduce to single value
$total = RecursiveApi::reduce($data,
    fn($acc, $val) => is_numeric($val) ? $acc + $val : $acc,
    0
);
```

Why Choose Concept-Labs Arrays?
-------------------------------

[](#why-choose-concept-labs-arrays)

### Advantages Over Standard PHP Arrays

[](#advantages-over-standard-php-arrays)

- **🎯 Cleaner Syntax**: `$data->get('user.profile.name')` vs `$data['user']['profile']['name'] ?? null`
- **🛡️ Safe Access**: No more `isset()` checks or null coalescing operators
- **🚀 Auto-path Creation**: Automatically creates intermediate arrays when setting values
- **🔧 Rich API**: 100+ methods vs manual implementations
- **🔍 Advanced Queries**: Wildcard patterns and SQL-like WHERE clauses
- **⚡ Performance**: Static API (RecursiveDotApi) has minimal overhead (~5% slower than native)

### Advantages Over Other Libraries

[](#advantages-over-other-libraries)

FeatureStandard ArraysLaravel Collectionsdflydev/dot**Concept-Labs**Dot Notation❌❌✅✅Wildcard Queries❌❌❌✅Functional Ops⚠️ Native only✅❌✅Path Operations❌❌⚠️ Limited✅ FullFramework Agnostic✅❌✅✅Static + OOP API⚠️ Native❌❌✅**[See full comparison →](docs/Comparison.md)**

Key Concepts
------------

[](#key-concepts)

### Dot Notation

[](#dot-notation)

Access nested array elements using dot-separated paths:

```
$array = [
    'database' => [
        'connections' => [
            'mysql' => [
                'host' => 'localhost'
            ]
        ]
    ]
];

// Instead of: $array['database']['connections']['mysql']['host']
// Use: $dotArray->get('database.connections.mysql.host')
```

### Mutable vs Immutable Operations

[](#mutable-vs-immutable-operations)

```
$data = new DotArray(['count' => 5]);

// Get returns a reference (mutable)
$ref = &$data->get('count');
$ref = 10; // Original data is modified

// Child with copy (immutable)
$child = $data->child('count', true);
$child->set('value', 20); // Original data unchanged

// Child with reference (mutable)
$child = $data->child('count', false);
$child->set('value', 20); // Original data is modified
```

Documentation
-------------

[](#documentation)

### Getting Started

[](#getting-started)

- **[Getting Started Guide](docs/Getting-Started.md)** - Step-by-step introduction for beginners
- **[Installation Guide](docs/Installation.md)** - Detailed installation and setup instructions

### Core Documentation

[](#core-documentation)

- **[DotArray Guide](docs/DotArray.md)** - Complete guide to DotArray object-oriented API
- **[RecursiveDotApi Guide](docs/RecursiveDotApi.md)** - Guide to static dot notation API
- **[RecursiveApi Guide](docs/RecursiveApi.md)** - Guide to basic recursive operations
- **[DotQuery Guide](docs/DotQuery.md)** - Advanced querying with wildcards

### Reference

[](#reference)

- **[API Reference](docs/API-Reference.md)** - Complete method reference
- **[Examples](docs/Examples.md)** - Real-world usage examples

Common Use Cases
----------------

[](#common-use-cases)

### Configuration Management

[](#configuration-management)

```
$config = new DotArray($defaultConfig);
$config->merge($userConfig);
$config->fill($requiredDefaults);
```

### Data Transformation

[](#data-transformation)

```
$data->walk(function(&$value, $path) {
    if (is_string($value)) {
        $value = trim($value);
    }
});
```

### Filtering &amp; Querying

[](#filtering--querying)

```
// Filter nested data
$adults = $users->filter(fn($u) => $u['age'] >= 18, 0, 'users');

// Query with wildcards (DotQuery)
$result = $query->select('users.*.name');
```

### Array Manipulation

[](#array-manipulation)

```
// Stack operations
$config->push('logs.entries', $newEntry);
$lastEntry = $config->pop('logs.entries');

// Numeric operations
$config->increment('stats.visits');
$config->decrement('stats.credits', 10);

// Boolean operations
$config->toggle('features.darkMode');
```

Advanced Features
-----------------

[](#advanced-features)

### Only/Except

[](#onlyexcept)

Extract or exclude specific paths:

```
$subset = $data->only(['user.name', 'user.email']);
$without = $data->except(['user.password', 'user.token']);
```

### Merge Strategies

[](#merge-strategies)

```
// Combine arrays
$data->merge($newData);

// Replace values
$data->replace($newData);

// Fill missing keys only
$data->fill($defaults);
```

### Flatten/Unflatten

[](#flattenunflatten)

```
$flat = $data->flatten(); // Convert to dot notation
$nested = $data->unflatten($flat); // Convert back to nested
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This library is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Credits
-------

[](#credits)

Developed by [Concept Labs](https://github.com/Concept-Labs)

Author: Viktor Halytskyi

Support
-------

[](#support)

- [Issue Tracker](https://github.com/Concept-Labs/arrays/issues)
- [Documentation](docs/)

Related Projects
----------------

[](#related-projects)

- [concept-labs/singularity](https://github.com/Concept-Labs/singularity) - PSR Container with powerful dependency injection

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance65

Regular maintenance activity

Popularity9

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

6

Last Release

218d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39bcfd110a5cc1f2d7ff687193670d00133cf415ad2b9959afaff24ff1e564fd?d=identicon)[vgalitsky](/maintainers/vgalitsky)

---

Top Contributors

[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (21 commits)")[![vgalitsky](https://avatars.githubusercontent.com/u/1241206?v=4)](https://github.com/vgalitsky "vgalitsky (20 commits)")

---

Tags

phpapiarray

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/concept-labs-arrays/health.svg)

```
[![Health](https://phpackages.com/badges/concept-labs-arrays/health.svg)](https://phpackages.com/packages/concept-labs-arrays)
```

###  Alternatives

[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
