Download the PHP package jbizzay/php-dot without Composer
On this page you can find all versions of the php package jbizzay/php-dot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jbizzay/php-dot
More information about jbizzay/php-dot
Files in jbizzay/php-dot
Package php-dot
Short Description Structured array helper with dot notation
License MIT
Informations about the package php-dot
PHP Dot Array
This repo is unmaintained. Check out this if you need something simliar: https://github.com/adbario/php-dot-notation
Helps manage arrays in PHP with dot notation. Useful for configs, meta data, or just working with large associative arrays.
Often, working with large arrays is cumbersome and prone to errors. Having to drill down into multiple levels of an array, checking isset all the way, is not fun.
Instead, you can do this:
It will simply return null, instead of throwing an undefined index error, if any part of the dot path doesn't exist. Also, working with dot notation makes code more readable and easier to write.
Usage
Create a Dot
Get
With no argument, get returns the entire data array. Pass a dot notation string to access parts of the data array.
Set
You can set any data type, including callable functions. Any levels that don't already exist, will be created as associative arrays. Set returns the same instance of Dot allowing for method chaining. Using a callable type will recieve the currently set value (if it exists) as an argument.
Unset
Unset a value, returns the dot instance
Has
Determines if a key is set
Define
Gets a value, but if the key is not set, initialize the key with a value. You can also use a callable type. By default, initializes with array. Returns the dot path value
Merge
Recursively merges an array into the dot array. First argument can be a dot path, an array, or a function that returns an array. The second argument can be an array or a function, but should only be used if first argument is a key. Returns the dot instance