RdbAdmin Module

ArrayUtil
in package

Array utilities class.

Tags
since
0.1

Table of Contents

Methods

__callStatic()  : mixed
Call static magic method.
arrayCustomMerge()  : array<string|int, mixed>
Array custom merge. Preserve indexed array key (numbers) but overwrite string key (same as PHP's `array_merge()` function).
inArrayI()  : bool
Checks if a value exists in an array (case insensitive).
isAssoc()  : bool
Check if associative array or indexed array?
recursiveKsort()  : mixed
Recursive sort array key.
staticRecursiveKsort()  : mixed
Static version of `recursiveKsort()`.

Methods

__callStatic()

Call static magic method.

public static __callStatic(string $name, mixed $arguments) : mixed
Parameters
$name : string
$arguments : mixed

arrayCustomMerge()

Array custom merge. Preserve indexed array key (numbers) but overwrite string key (same as PHP's `array_merge()` function).

public arrayCustomMerge(array<string|int, mixed> $array1, array<string|int, mixed> ...$arrays) : array<string|int, mixed>

If the another array key is string, it will be overwrite the first array.
If the another array key is integer, it will be add to first array depend on duplicated key or not. If it is not duplicate key with the first, the key will be preserve and add to the first array. If it is duplicated then it will be re-index the number append to the first array.

Parameters
$array1 : array<string|int, mixed>

The first array is main array.

$arrays : array<string|int, mixed>

The another arrays to merge with the first.

Tags
since
1.1.1
Return values
array<string|int, mixed>

Return merged array.

inArrayI()

Checks if a value exists in an array (case insensitive).

public inArrayI(mixed $needle, array<string|int, mixed> $haystack) : bool
Parameters
$needle : mixed

The searched value.

$haystack : array<string|int, mixed>

The array.

Tags
link

code reference.

link

in_array() function reference.

Return values
bool

Returns true if needle is found in the array, false otherwise.

recursiveKsort()

Recursive sort array key.

public recursiveKsort(array<string|int, mixed> &$array[, int $sortFlags = SORT_REGULAR ]) : mixed
Parameters
$array : array<string|int, mixed>

The array.

$sortFlags : int = SORT_REGULAR

You may modify the behavior of the sort using the optional parameter sortFlag, for details see sort().

Tags
link

ksort() function.

link

sort() function.

link

Original source code.

staticRecursiveKsort()

Static version of `recursiveKsort()`.

public static staticRecursiveKsort(array<string|int, mixed> &$array[, mixed $sortFlags = SORT_REGULAR ]) : mixed

The method recursiveKsort() can't call using magic call static because it is required to call itself using $this.
This static version will initialize the class with new self().

Parameters
$array : array<string|int, mixed>
$sortFlags : mixed = SORT_REGULAR
Tags
see
ArrayUtil::recursiveKsort()

This is an alias method of recursiveKsort().


        
On this page

Search results