ArrayHelper
class ArrayHelper
Class ArrayHelper
Methods
Determine whether the given value is array accessible.
Determines if an array is associative.
No description
Get Multi - 获取多个, 可以设置默认值
递归合并两个多维数组,后面的值将会递归覆盖原来的值
递归合并多个多维数组,
清理数组值的空白
不区分大小写检测数据键名是否存在
No description
No description
将数组中的值全部转为大写或小写
******* 检查 一个或多个值是否全部存在数组中 ******* 有一个不存在即返回 false
******* 检查 一个或多个值是否存在数组中 ******* 有一个存在就返回 true 都不存在 return false
******* 不区分大小写,检查 一个或多个值是否 全存在数组中 ******* 有一个不存在即返回 false
******* 不区分大小写,检查 一个或多个值是否存在数组中 ******* 有一个存在就返回 true 都不存在 return false
get key Max Width
Get data from array or object by path.
Collapse an array of arrays into a single array.
Cross join the given arrays, returning all possible permutations.
Divide an array into two arrays. One with keys and the other with values.
Flatten a multi-dimensional associative array with dots.
Get all of the given array except for a specified array of items.
Determine if the given key exists in the provided array.
Add an element to an array using "dot" notation if it doesn't exist.
Get an item from an array using "dot" notation.
Set an array item to a given value using "dot" notation.
Flatten a multi-dimensional array into a single level.
Remove one or many array items from a given array using "dot" notation.
Check if an item or items exist in an array using "dot" notation.
Push an item onto the beginning of an array.
remove the $key of the $arr, and return value.
Get a value from the array, and remove it.
Get a subset of the items from the given array.
Shuffle the given array and return the result.
Filter the array using the given callback.
If the given value is not an array, wrap it in one.
array 递归 转换成 字符串
No description
No description
No description
Details
at line 25
static bool
accessible(mixed $value)
Determine whether the given value is array accessible.
at line 36
static bool
isAssoc(array $array)
Determines if an array is associative.
An array is "associative" if it doesn't have sequential numerical keys beginning with zero.
at line 47
static Traversable
toIterator(mixed $array)
at line 62
static mixed
toObject(array|Traversable $array, string $class = \stdClass::class)
array data to object
at line 91
static array
gets(array $data, array $needKeys = [], bool|false $unsetKey = false)
Get Multi - 获取多个, 可以设置默认值
at line 131
static array
merge(array|null $src, array $new)
递归合并两个多维数组,后面的值将会递归覆盖原来的值
at line 165
static array
merge2(array ...$args)
递归合并多个多维数组,
at line 197
static array|string
valueTrim(array $data)
清理数组值的空白
at line 216
static bool
keyExists(int|string $key, array $arr)
不区分大小写检测数据键名是否存在
at line 225
static array
valueToLower(array $arr)
at line 234
static array
valueToUpper(array $arr)
at line 245
static array
changeValueCase(array $arr, int $toUpper = 1)
将数组中的值全部转为大写或小写
at line 270
static bool
valueExistsAll(string|array $check, array $sampleArr)
******* 检查 一个或多个值是否全部存在数组中 ******* 有一个不存在即返回 false
at line 288
static bool
valueExistsOne(string|array $check, array $sampleArr)
******* 检查 一个或多个值是否存在数组中 ******* 有一个存在就返回 true 都不存在 return false
at line 307
static bool
existsAll(string|array $need, array $arr, bool $type = false)
******* 不区分大小写,检查 一个或多个值是否 全存在数组中 ******* 有一个不存在即返回 false
at line 341
static bool
existsOne(string|array $need, array $arr, bool $type = false)
******* 不区分大小写,检查 一个或多个值是否存在数组中 ******* 有一个存在就返回 true 都不存在 return false
at line 378
static int
getKeyMaxWidth(array $data, bool $expectInt = true)
get key Max Width
at line 403
static mixed
getByPath(array|ArrayAccess $data, string $path, mixed $default = null, string $separator = '.')
Get data from array or object by path.
Example: DataCollector::getByPath($array, 'foo.bar.yoo')
equals to $array['foo']['bar']['yoo'].
at line 438
static
setByPath(array|ArrayAccess $data, string $path, mixed $value, string $separator = '.')
setByPath
at line 478
static array
collapse(array $array)
Collapse an array of arrays into a single array.
at line 500
static array
crossJoin(array ...$arrays)
Cross join the given arrays, returning all possible permutations.
at line 516
static array
divide(array $array)
Divide an array into two arrays. One with keys and the other with values.
at line 527
static array
dot(array $array, string $prepend = '')
Flatten a multi-dimensional associative array with dots.
at line 548
static array
except(array $array, array|string $keys)
Get all of the given array except for a specified array of items.
at line 561
static bool
exists(ArrayAccess|array $array, string|int $key)
Determine if the given key exists in the provided array.
at line 577
static array
add(array $array, string $key, mixed $value)
Add an element to an array using "dot" notation if it doesn't exist.
at line 593
static mixed
get(ArrayAccess|array $array, string $key, mixed $default = null)
Get an item from an array using "dot" notation.
at line 626
static array
set(array $array, string $key, mixed $value)
Set an array item to a given value using "dot" notation.
If no key is given to the method, the entire array will be replaced.
at line 657
static array
flatten(array $array, int $depth = INF)
Flatten a multi-dimensional array into a single level.
at line 680
static void
forget(array $array, array|string $keys)
Remove one or many array items from a given array using "dot" notation.
at line 722
static bool
has(ArrayAccess|array $array, string|array $keys)
Check if an item or items exist in an array using "dot" notation.
at line 765
static array
prepend(array $array, mixed $value, mixed $key = null)
Push an item onto the beginning of an array.
at line 783
static mixed
remove($arr, $key, $default = null)
remove the $key of the $arr, and return value.
at line 802
static mixed
pull(array $array, string $key, mixed $default = null)
Get a value from the array, and remove it.
at line 817
static array
only(array $array, array|string $keys)
Get a subset of the items from the given array.
at line 827
static array
shuffle(array $array)
Shuffle the given array and return the result.
at line 840
static array
where(array $array, callable $callback)
Filter the array using the given callback.
at line 850
static array
wrap(mixed $value)
If the given value is not an array, wrap it in one.
at line 870
static string
toString(array $array, int $length = 800, array|int $cycles = 6, bool $showKey = true, bool $addMark = false, string $separator = ', ', string $string = '')
array 递归 转换成 字符串