Berserker bArrays Class

Berserker bArrays Class was made to simulate a package for the native array functions of PHP.

PHP berserker official image

The berserker project offer you 2 approaches, using static classes or instantiated methods. This is not interchangeable. You select the approach you want when you instantiate berserker class, check Composer version at https://blastcoding.com/en/php-berserker/

static class:

bArrays::

instantiated method:

bArrays->

Berserker bArrays Class methods

ok, let’s see what methods offer bArrays for now:

uppercaseKeys

– uses PHP array_change_key_case

Description / Descripción
uppercaseKeys($array):array

lowercaseKeys

– uses PHP array_change_key_case

Description / Descripción
lowercaseKeys($array):array

chunk 

– uses PHP array_chunk

Description / Descripción
chunk(array $array, int $length, bool $preserve_keys = false): array

column 

– uses PHP array_column

Description / Descripción
column(array $array, int|string|null $column_key, int|string|null $index_key = null): array

valueExists 

– uses PHP in_array

Description / Descripción
valueExists(mixed $needle, array $haystack, bool $strict = false): bool

keyExists 

– uses PHP array_key_exists

Description / Descripción
keyExists(string|int|float|bool|null $key, array $array): bool

valueOccurrences 

– uses PHP array_count_values

Description / Descripción
valuesOccurrences(array $array): array

ascendingSort 

– uses PHP sort

Description / Descripción
ascendingSort(array &$array, int $flags = SORT_REGULAR): true

descendingSort 

– uses PHP rsort

Description / Descripción
descendingSort(array &$array, int $flags = SORT_REGULAR): true

ascendingKeySort 

– uses PHP ksort

Description / Descripción
ascendingKeySort(array &$array, int $flags = SORT_REGULAR): true

descendingKeySort 

– uses PHP krsort

Description / Descripción
descendingKeySort(array &$array, int $flags = SORT_REGULAR): true

keys 

– uses PHP array_keys

Description / Descripción
keys(array $array, mixed $filter_value = null, bool $strict = false): array

firstKey 

– uses PHP array_key_first

Description / Descripción
firstKey(array $array): int|string|null

lastKey 

– uses PHP array_key_last

Description / Descripción
lastKey(array $array): int|string|null