Download the PHP package jdrieghe/array-helpers without Composer
On this page you can find all versions of the php package jdrieghe/array-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jdrieghe/array-helpers
More information about jdrieghe/array-helpers
Files in jdrieghe/array-helpers
Package array-helpers
Short Description A collection of convenience methods to deal with arrays in php. Somewhat inspired by Laravel array helpers.
License MIT
Informations about the package array-helpers
Purpose
This package was inspired by some of the great array helper functions in Laravel.
Having to include all of Illuminate\Support
is sometimes a bit too much for a given project, so I decided to build
a separate package to provide some much needed framework independent array magic.
Installation
Installation can be done easily through composer.
Usage
Static approach
You can choose to use only the static helper methods.
Functional approach
If you prefer a more functional approach, some namespaced convenience methods are available as well:
Available helpers
Array Get
This helper allows you to get an item from an array using dot notation. If the item is not found, it will return a given default or null.
Note that Arr::get()
can be replaced with array_get()
if you prefer a functional approach.
Array Has
This helper checks if an item exists in an array using dot notation.
Note that Arr::has()
can be replaced with array_has()
if you prefer a functional approach.
Array Set
This helper sets a certain key in an array to a certain value. Dot notation can be used to create a deeply nested key.
$data
now contains:
Note that Arr::set()
can be replaced with array_set()
if you prefer a functional approach.