Download the PHP package friendly-pixel/ar without Composer

On this page you can find all versions of the php package friendly-pixel/ar. 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 ar

Ar makes working with PHP arrays easy

Fluent style:

Functional style:

Install

Install the latest version using Composer:

Methods

Fluent style only:

count

Count how many items there are in the array.

filter

Pass every value, key into a user-supplied callable, and only put the item into the result array if the returned value is true. Keys are preserved only when array_is_list($array) returns false;

@template A

@param A[] $array

@param callable(A $value, mixed $key): bool $callable

@return A[]

first

Returns the first value of the array or false when it's empty.

@template A

@param A[] $array

@return A

flat

The flat() method creates a new array with all sub-array elements concatenated into it recursively up to the specified depth.

@param int $depth To what level to flatten the array. Default: 1

@return mixed[]

forEach

Walk over every value, key. Pass every value, key into a user-supplied callable.

@template A

@param A[] $array

@param callable(A $value, mixed $key): void $callable

@return A[] Original array, unmodified

implode

Join all values into a big string, using $glue as separator. $glue is optional.

keys

Return the keys of an array as a sequential array.

@return mixed[]

last

Returns the last value of the array or false when it's empty.

@template A

@param A[] $array

@return A

map

Transform values. Pass every value, key into a user-supplied callable, and put the returned value into the result array. Keys are preserved.

@template A

@template B

@param A[] $array

@param callable(A $value, mixed $key): B $callable

@return B[]

mapKeys

Transform keys. Pass every value, key and key into a user-supplied callable, and use the returned value as key in the result array.

@template A

@template K

@param A[] $array

@param callable(A $value, mixed $key): K $callable

@return array<K, A>

merge

Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended. Values in the input arrays with numeric keys will be renumbered with incrementing keys starting from zero in the result array.

@template A

@var A[][] $arrays

@return A[]

push

Append one or more items to the end of array.

@template A

@param A[] $array

@param A[] $values

@return A[]

reduce

Iteratively reduce the array to a single value using a callback function.

@template A

@template B

@param A[] $array

@param callable(B|null $carry, A $value, mixed $key): B $callable

@param B|null $initial If the optional initial is available, it will be used at the beginning of the process, or as a final result in case the array is empty.

@return B

search

Return the first value for which the callable returns true. Returns null otherwise.

@template A

@param A[] $array

@param callable(A $value, mixed $key): bool $callable

@return A|null

slice

Extract a slice of the array, include $length items, and starting from $offset.

@template A

@param A[] $array

@param int $offset If offset is non-negative, the sequence will start at that offset in the array. If offset is negative, the sequence will start that far from the end of the array.

@param ?int $length If length is given and is positive, then the sequence will have up to that many elements in it. If the array is shorter than the length, then only the available array elements will be present. If length is given and is negative then the sequence will stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from offset up until the end of the array.

@return A[]

sort

Sort an array by values using a user-defined comparison function.

This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned.

@template A

@param A[] $array

@param callable(A $valueA, A $valueB): int $callable
Return an integer smaller then, equal to, or larger than 0 to indicate that $valueA is less then, equal to, or larger than $valueB.

@return A[]

splice

Remove a portion of the array and replace it with something else. Other than the default php function, this returns the changed array, not the extracted elements.

@template A

@param A[] $array

@param int $offset If offset is positive then the start of the removed portion is at that offset from the beginning of the array.

 If offset is negative then the start of the removed portion is at that offset from 
 the end of the array. 

@param ?int $length If length is omitted, removes everything from offset to the end of the array. * If length is specified and is positive, then that many elements will be removed.

 If length is specified and is negative, then the end of the removed portion will be 
 that many elements from the end of the array.

 If length is specified and is zero, no elements will be removed. 

@param A[] $replacement If replacement array is specified, then the removed elements are replaced with elements from this array.

 If offset and length are such that nothing is removed, then the elements from the 
 replacement array are inserted in the place specified by the offset. 
 *
 If replacement is just one element it is not necessary to put array() or square brackets 
 around it, unless the element is an array itself, an object or null. 

 Note: Keys in the replacement array are not preserved.

@return A[] Other than the default php function, this returns the changed array, not the extracted elements.

unique

Remove duplicate values from array. Keys are preserved only when array_is_list($array) returns false;

@template A

@param A[] $array

@return A[]

unshift

Prepend one or more items to the beginning of array.

@template A

@param A[] $array

@param A[] $values

@return A[]

values

Return the values of an array as a sequential array.

@template A

@param array<mixed, A> $array

@return array<int, A>

Fluent style only methods

wrap

Wrap an array, so you can use fluent syntax to call multiple methods on it. Use ->unwrap() at the end if you need a pure array again.

unwrap

Return the underlying array.

toArray

Alias for unwrap()

License

MIT license


All versions of ar with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
symfony/polyfill-php81 Version ^1.24
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 friendly-pixel/ar contains the following files

Loading the files please wait ....