Download the PHP package sajadsdi/array-dot-notation without Composer
On this page you can find all versions of the php package sajadsdi/array-dot-notation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sajadsdi/array-dot-notation
More information about sajadsdi/array-dot-notation
Files in sajadsdi/array-dot-notation
Package array-dot-notation
Short Description set and get with dot notation in arrays
License MIT
Informations about the package array-dot-notation
Array Dot Notation
Array Dot Notation is a high-performance and lightweight PHP library that allows you to set and get values in arrays using dot notation. It simplifies working with nested arrays by providing an intuitive way to access and modify data.
Features
- Get values from arrays using dot notation keys.
- Set values in arrays using dot notation keys.
- Delete key(s) from array using dot notation.
- Check if a key or multi keys exists in an array using dot notation.
- Check if one key from keys is exists in an array...
- Map keys for output data in get operations.
- single and multiple default value for
get
function - callback for when to return the default value for each key in
get
function - callback for when set ech keys in
set
function
Installation
You can install this library using Composer. If you haven't already set up Composer for your project, you can do so by following the official Composer installation guide.
Once Composer is installed, run the following command to install Array Dot Notation:
Usage
Basic Usage
Here's how you can use Array Dot Notation in your PHP project:
Advanced Usage
Example 1: Getting Multiple Values Simultaneously
You can retrieve multiple values simultaneously using dot notation:
Example 2: Mapping Keys for Output Data in Get
You can map keys for the output data when using the get
method:
Example 3: Automatic Key Handling for Duplicate Keys
When you get values without using a map, the library will automatically handle duplicate keys:
Example 4: Automatic Key Handling for Numeric Keys
When the last key is a numeric index, it will use the input array index:
Example 5: Using get
with a Single Default Value
In this example, we retrieve the value of the "user.profile.name" key from the data. This key doesn't exist, the default value "Guest" is returned.
Example 6: Using get
with a Single Default Value and an Existing Key
In this example, we retrieve the value of the "user.profile.pic" key from the data. Since this key exists in the data, the actual value of the key is returned, and the default value is ignored.
Example 7: Using get
with Multiple Default Values
In this example, we retrieve the values of the "user.profile.name" and "user.profile.bio" keys from the data. If either of these keys doesn't exist, the corresponding default values are returned for each key.
Example 8: Using multiple get
with one Default Value
In this example, we retrieve the values of the "user.profile.name" and "user.profile.bio" keys from the data. If either of these keys doesn't exist, default value are returned for each key.
Example 9: Using multiple key in has
method
In this example, we check for exist the "user.profile.name" and "user.profile.bio" keys in the data. if all keys exists in the data ,true returned.
Example 10: Using hasOne
method
if one of all keys exist in the data ,true returned.
These examples demonstrate the advanced capabilities of the Array Dot Notation library for handling various scenarios when accessing and manipulating nested arrays using dot notation.
Contributing
We welcome contributions from the community to improve and extend this library. If you'd like to contribute, please follow these steps:
- Fork the repository on GitHub.
- Clone your fork locally.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with clear, concise commit messages.
- Push your changes to your fork on GitHub.
- Submit a pull request to the main repository.
Reporting Bugs and Security Issues
If you discover any security vulnerabilities or bugs in this project, please let us know through the following channels:
-
GitHub Issues: You can open an issue on our GitHub repository to report bugs or security concerns. Please provide as much detail as possible, including steps to reproduce the issue.
- Contact: For sensitive security-related issues, you can contact us directly through the following contact channels
Contact
If you have any questions, suggestions, financial, or if you'd like to contribute to this project, please feel free to contact the maintainer:
- Email: [email protected]
We appreciate your feedback, support, and any financial contributions that help us maintain and improve this project.
License
This library is open-source software licensed under the MIT License.