Download the PHP package knot/knot without Composer
On this page you can find all versions of the php package knot/knot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package knot
Knot
Knot is a very powerful tool for array. Knot help for using arrays like objects! And Knot have very rich function library.
Simple Example;
In this example, first Knot created and Knot's data have for now. Then $obj's data is merged with . Then function called and $obj's data changed. The next line, created child key in data and equalized to . In the last line, $obj's data is converted to Array.
Knot is prepared with PSR-0 and PSR-1 standards.
Documentation
Visit documentation for more information.
Install
Knot is available for Composer.
composer require knot/knot
Or download from Github.
Use like Array
Knot object can be used like Arrays. Because Knot have ArrayAccess interface.
Example:
Knot's data can be changed with this way.
Other Using Ways
Also method can be access to Knot's data. But if target is an Array, then return Knot Child. So functions can be used with recursive.
Also functions can be changed to Knot's data.
Example:
This is a point to take into consideration. If trying to setting nonexistent way, then Knot's data merged with stdClass objects.
Example:
In this example, $obj's data's key is changed with stdClass object.
Base Functions
Knot have many functions. Also It can be added new functions to Knot.
Knot Functions
Knot have many own functions.
get($path, [$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:
In this example's target is "sub" key of "foo" of Knot's data.
Let's get target with this way.
Example:
Also can be used with default value. If have default value and target nonexistent, then create target and change this value to default value.
If target is nonexistent and default value doesn't given, then throws an error.
In addition, if target is an array, then Knot will return Knot Child for recursive using.
set($path, $value)
use same thing that functions address usage. 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)
use same thing that functions address usage. delete targets.
License
The Knot is open-sourced software licensed under the MIT license.