Download the PHP package tezmanian/utils-arr without Composer
On this page you can find all versions of the php package tezmanian/utils-arr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tezmanian/utils-arr
More information about tezmanian/utils-arr
Files in tezmanian/utils-arr
Package utils-arr
Short Description A set of focused PHP array utilities: grouping, pagination, diffing, sorting, partitioning, flattening, cartesian products, and more — PHP 8.3+, no framework required.
License MIT
Homepage https://github.com/tezmanian/tez-utils-arr
Informations about the package utils-arr
tez-utils-arr
A collection of focused, stateless array utility classes for PHP 8.3+. Each class does one thing and exposes a clean static API.
Installation
Package: tezmanian/utils-arr · Namespace: Tezmanian\Utils\Arr
Components
| Class | Purpose |
|---|---|
ArrayDiff |
Recursively compares two arrays and returns all differences with dot-notation paths |
CartesianProduct |
Computes the Cartesian product of any number of sets lazily via a Generator |
DeepMerge |
Recursively merges override arrays into a base array |
Find |
Returns the first or last item matching a predicate |
Flatten |
Flattens a nested array into a single list |
GroupBy |
Groups items by a key derived from a callback |
KeyBy |
Builds an associative lookup map from a list |
MapWithKeys |
Maps over an array where the callback returns a [key => value] pair |
Paginator |
Paginates an array and returns an immutable Page with slice and metadata |
Partition |
Splits an array into two lists in a single pass |
Pluck |
Extracts values from an array of records using dot-notation keys |
SafeGet |
Safely reads typed values from deeply nested arrays using dot-notation paths |
Sliding |
Produces consecutive overlapping windows of a fixed size |
SortBy |
Sorts a copy of the array by a derived key |
Transpose |
Swaps rows and columns of a 2D array |
UniqueBy |
Removes duplicates where uniqueness is determined by a callback |
Wrap |
Ensures any value is an array |
Zip |
Combines multiple arrays element-by-element into a list of tuples |
ArrayDiff
Recursively compares two arrays and returns all differences with dot-notation paths.
Comparison is strict (1 !== "1"). Keys are reported as ChangeType::Added, ChangeType::Removed, or ChangeType::Changed.
CartesianProduct
Computes the Cartesian product of any number of sets lazily via a Generator.
No intermediate array is built — suitable for large input sets.
DeepMerge
Recursively merges override arrays into a base array. Multiple overrides are applied left to right.
String keys are merged recursively when both sides are arrays. Integer keys are appended (like array_merge). Scalar values on the right side always win.
Find
Returns the first or last item matching a predicate.
Flatten
Flattens a nested array into a single list. Accepts an optional depth limit.
GroupBy
Groups items by a key derived from a callback.
KeyBy
Builds an associative lookup map from a list. When two items produce the same key, the last wins.
MapWithKeys
Maps over an array where the callback returns a [key => value] pair.
Paginator
Paginates an array and returns an immutable Page with slice and metadata.
Throws InvalidArgumentException when $page < 1 or $perPage < 1.
Partition
Splits an array into two lists in a single pass — items passing the predicate first, failing items second.
Pluck
Extracts values from an array of records using dot-notation keys.
Items where the key is absent are silently skipped.
SafeGet
Safely reads typed values from deeply nested arrays using dot-notation paths. Returns null (or a default) when any segment is missing.
Integer-looking segments (e.g. "0") address list indices automatically.
Sliding
Produces consecutive overlapping windows of a fixed size.
SortBy
Sorts a copy of the array by a derived key. Never mutates the original. Result is always re-indexed.
Transpose
Swaps rows and columns of a 2D array. All rows must have the same column count.
UniqueBy
Removes duplicates where uniqueness is determined by a callback.
Wrap
Ensures any value is an array. null becomes [], arrays pass through, everything else gets wrapped.
Zip
Combines multiple arrays element-by-element into a list of tuples.
Requirements
- PHP 8.3+
tezmanian/utils-enum^1.0
Development
License
MIT — see LICENSE.
Author: René Halberstadt