Download the PHP package mleczek/collections without Composer

On this page you can find all versions of the php package mleczek/collections. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package collections

PHP Collections

This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Installation

Getting started

Convert any array to collection:

You can also do this using collection helper method:

Available operations

addFirst

Add item at the beginning of the collection.

addLast

Add item at the end of the collection.

avg

Calculate average value from items. Zero if there're no items in collection.

Throws when trying to calculate avg from non-number value.

chunk

Breaks into multiple, smaller collections of a given size.

E.g. for chunk size 2 the output array for [1, 2, 3] will be [[1, 2], [3]].

count

The total number of items in the collection.

each

Iterate over each item.

firstKey

Get first item key.

first

Get first item value.

flatten

Convert array of arrays to array (remove one dimension).

groupBy

Groups the collection's items by a given key.

has

Check whether collection has items which match given closure.

isAssociative

Check whether collection is an associative array.

See also isIndexed method.

isEmpty

Check whether collection has zero items.

isIndexed

Check whether collection is an indexed array.

See also isAssociative method.

isNotEmpty

Check whether collection has any item.

join

Join all items with given glue.

keyBy

Change collection's items keys.

If multiple items have the same key, the exception will be thrown.

keys

Returns all of the collection's keys.

lastKey

Get last item key.

last

Get last item value.

map

Iterates through the collection and modify each item.

Array keys are preserved.

max

Get maximum value from items.

The ">" operator is used to find maximum value.

merge

Merge collection/array to current array.

In associative arrays values for existing keys will be overwrite. In indexed arrays new values are always appended at the end of collection.

min

Get minimum value from items.

The "<" operator is used to find minimum value.

randomKey

Get random key from collection.

Returns null if collection is empty.

random

Get random item value.

Returns null if collection is empty.

reduce

Reduces the collection to a single value, passing the result of each iteration into the subsequent iteration.

removeFirst

Remove first N items from collection.

removeLast

Remove last N items from collection.

reverse

Reverse items order.

skip

Skip N first items.

sortDesc

Sort items descending.

Strings are sorted in case insensitive manner.

See also sort method.

sort

Sort items ascending.

Strings are sorted in case insensitive manner.

See also sortDesc method.

sum

Returns the sum of all items in the collection.

Throws when trying to calculate sum from non-number value.

take

Take N first items.

toArray

Returns collection's items.

unique

Left only items with unique value.

First occurrence is taken if multiple same values are encountered.

values

Returns all of the collection's values (as indexed array).

whereIn

Return collection with items that needle is in haystack of accepted values.

where

Return collection with items which match given criteria.


All versions of collections with dependencies

PHP Build Version
Package Version
Requires php Version ~7.4 || ~8.0
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mleczek/collections contains the following files

Loading the files please wait ....