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