PHPackages                             knot/knot - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. knot/knot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

knot/knot
=========

Modern Array collection for PHP

v1.0.1(10y ago)19201[1 issues](https://github.com/kalaomer/knot/issues)MITPHPPHP &gt;=5.4.0

Since Jun 18Pushed 10y ago4 watchersCompare

[ Source](https://github.com/kalaomer/knot)[ Packagist](https://packagist.org/packages/knot/knot)[ RSS](/packages/knot-knot/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

Knot
====

[](#knot)

[![Build Status](https://camo.githubusercontent.com/8cfbf9e99c8589fb1207033a8e49a678c91a3ad2989ebd422cee4710ef1b0beb/68747470733a2f2f7472617669732d63692e6f72672f6b616c616f6d65722f6b6e6f742e7376673f6272616e63683d76312e312e32)](https://travis-ci.org/kalaomer/knot)[![Dependency Status](https://camo.githubusercontent.com/be94d63141c7f3ab3d7218a71e9266f4148126c4d3181b641f7b02b0ccd2781a/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3533353330323930666530643037396166393030303164352f62616467652e706e67)](https://www.versioneye.com/user/projects/53530290fe0d079af90001d5)[![Latest Version](https://camo.githubusercontent.com/4c79088fe8efaca10d53e0d79bb39503abd4fc2e686beede8ae2fd6697b0bf0f/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6b616c616f6d65722f6b6e6f742e737667)](https://github.com/kalaomer/knot/releases)[![Coverage Status](https://camo.githubusercontent.com/3e2c3f1e4ab3752071189ae42b4273d801c2f2a908e782ee1c017384ac92b738/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b616c616f6d65722f6b6e6f742f62616467652e706e67)](https://coveralls.io/r/kalaomer/knot)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9243644ed6c19e6dd48a3c4f79a926c9e2ffe9effbc81ced1937943e6b4e8c1f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b616c616f6d65722f6b6e6f742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kalaomer/knot/?branch=master)[![Codeship Status](https://camo.githubusercontent.com/182bc8e2a5a65a497f2c4838c244097260ba63ea3ab32fb7524ace695d36d075/68747470733a2f2f636f6465736869702e636f6d2f70726f6a656374732f37353064656135302d643435372d303133322d393262352d3261356562653734383339362f7374617475733f6272616e63683d6d6173746572)](https://codeship.com/projects/750dea50-d457-0132-92b5-2a5ebe748396/status?branch=master)

Knot is a very powerful tool for array. Knot help for using arrays like objects! And Knot have very rich function library.

Simple Example;

```
$obj = ar(1,2,3);

$obj->merge(array(3,3,4,5,6,7))->unique();

$obj->child = array("a", "b", "c");

$array = $obj->toArray();
```

In this example, first Knot created and Knot's data have `array(1,2,3)` for now. Then $obj's data is merged with `array(3,3,4,5,6,7)`. Then `array_unique` function called and $obj's data changed. The next line, created child key in data and equalized to `array("a", "b", "c")`. In the last line, $obj's data is converted to Array.

Knot is prepared with [PSR-0](http://www.php-fig.org/psr/psr-0/) and [PSR-1](http://www.php-fig.org/psr/psr-1/) standards.

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

[](#documentation)

Visit [documentation](https://kalaomer.github.io/knot) for more information.

Install
-------

[](#install)

Knot is available for Composer.

```
composer require knot/knot

```

Or download from [Github](https://github.com/kalaomer/knot/archive/master.zip).

### Use like Array

[](#use-like-array)

Knot object can be used like Arrays. Because Knot have [ArrayAccess](http://www.php.net/manual/en/class.arrayaccess.php) interface.

Example:

```
$obj = ar();

$obj["new"]["way"] = "new way value";

$obj[][][][] = 1;
```

Knot's data can be changed with this way.

### Other Using Ways

[](#other-using-ways)

Also `__get` method can be access to Knot's data. But if target is an Array, then `get` return Knot Child. So functions can be used with recursive.

Also `__set` functions can be changed to Knot's data.

Example:

```
$obj = ar();

$obj->new = array(
    "way" => "new value"
);

// Returns array("way" => "new value")
$obj->new->toArray();
```

This is a point to take into consideration. If trying to setting nonexistent way, then Knot's data merged with stdClass objects.

Example:

```
$obj = ar();

$obj->new->way->foo = 1;
```

In this example, $obj's data's `new` key is changed with stdClass object.

Base Functions
--------------

[](#base-functions)

Knot have many functions. Also It can be added new functions to Knot.

### Knot Functions

[](#knot-functions)

Knot have many own functions.

#### get($path, \[$default\_value\])

[](#getpath-default_value)

Knot can find target data with address. So Knot can find target with small commands.

Knot using `.` letter for show address.

Example Address: `foo.sub.target`

In this example's target is "sub" key of "foo" of Knot's data.

Let's get target with this way.

Example:

```
$obj = arr(array(
    "foo" => array(
        "sub" => array(
            "target" => 123
        )
    )
));

// Returns $obj["foo"]["sub"]["target"]
$target = $obj->get("foo.sub.target");
```

Also `get` can be used with default value. If `get` have default value and target nonexistent, then `get` create target and change this value to default value.

If target is nonexistent and default value doesn't given, then `get` throws an error.

In addition, if target is an array, then Knot will return Knot Child for recursive using.

#### set($path, $value)

[](#setpath-value)

`set` use same thing that `get` functions address usage. `set` change to value from target of Knot's data.

If changed value is an array, Knot return Knot Child so

In addition, if target is an array, then Knot will return Knot Child for recursive using.

#### del($path)

[](#delpath)

`del` use same thing that `get` functions address usage. `del` delete targets.

License
-------

[](#license)

The Knot is open-sourced software licensed under the [MIT license](https://raw.githubusercontent.com/kalaomer/knot/master/LICENSE.txt).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% 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 ~187 days

Total

2

Last Release

3800d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a853d28d38d0717a9760c06bed9ef75710209ad449825b54234d609e799def24?d=identicon)[grandsopikat](/maintainers/grandsopikat)

---

Top Contributors

[![kalaomer](https://avatars.githubusercontent.com/u/2925345?v=4)](https://github.com/kalaomer "kalaomer (86 commits)")[![royopa](https://avatars.githubusercontent.com/u/442991?v=4)](https://github.com/royopa "royopa (1 commits)")

---

Tags

arraytoolobjectcollection

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/knot-knot/health.svg)

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

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[lorisleiva/lody

Load files and classes as lazy collections in Laravel.

956.6M9](/packages/lorisleiva-lody)[yansongda/supports

common components

211.4M31](/packages/yansongda-supports)

PHPackages © 2026

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