Download the PHP package marsapp/arrayhelper without Composer
On this page you can find all versions of the php package marsapp/arrayhelper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marsapp/arrayhelper
More information about marsapp/arrayhelper
Files in marsapp/arrayhelper
Package arrayhelper
Short Description ArrayHelper liberary, providing functions such as rebuilding indexes, grouping, getting content, recursive difference sets, recursive sorting, etc.
License MIT
Homepage https://github.com/marshung24/ArrayHelper
Informations about the package arrayhelper
ArrayHelper
Array processing library, providing functions such as rebuilding indexes, grouping, getting content, recursive difference sets, recursive sorting, etc.
Continuation library marshung/helper, only keep and maintain ArrayHelper
Outline
- Installation
- Usage
- Example
- API Reference
- indexBy()
- groupBy()
- indexOnly()
- getContent()
- getFallContent()
- gather()
- diffRecursive()
- sortRecursive()
- filterKey()
Installation
Composer Install
Include
Include composer autoloader before use.
Usage
Example
Namespace use:
API Reference
indexBy()
Data re-index by keys
Since $data is a reference, $data will change after indexBy() is executed.
Since $data is a reference, the return is useless.
If you want to keep $data, you can clone it before using it.
Example :
groupBy()
Data re-index and Group by keys
Since $data is a reference, $data will change after indexBy() is executed.
Since $data is a reference, the return is useless.
If you want to keep $data, you can clone it before using it.
Example :
$data reqult:
indexOnly()
Data re-index by keys, No Data
Since $data is a reference, $data will change after indexBy() is executed.
Since $data is a reference, the return is useless.
If you want to keep $data, you can clone it before using it.
Example :
$data reqult:
getContent()
Get Data content by index
Example:
getFallContent()
Get fall point content
- Get the data in an ordered non-contiguous index array
- If there is no fall point, return null.
- Ensure performance by sorting $data ahead of time:
- a. Sorting $data (ASC)
- b. Close $sortOut
- c. Use function ArrayHelper::getFallContent()
Parameters
- $data: The array to compare from. array
- $referKey: Refer key to compare against. string
- $sortOut: Whether the input needs to be rearranged. Value: true, false, 'default'. If it is 'default', see getSortOut()
Return Values
- Returns the resulting mixed.
Example :
gather()
Data gather by list
Collect and classify target data according to the list of fields
Example Data :
Example 1 :
Field
manager
,s_manager
,c_user values
are placed in the same one-dimensional array
$ssnList1 reqult:
Example 2 :
The field
manager
is placed in an array, the fieldss_manager
, and thec_user
values are placed in the same array. Form a 2-dimensional array
$ssnList2 reqult:
diffRecursive()
Array Deff Recursive
Compare $srcArray with $contrast and display it if something on $srcArray is not on $contrast.
Example :
$diff result :
sortRecursive()
Array Sort Recursive
$srcArray is a reference
$type : ksort(default), krsort, sort, rsort
Example :
$data1 result:
$data2 result:
filterKey()
Filter array according to the allowed keys
Parameters
- $array: The array to compare from. array
- $keys: Key list to compare against. array|string
- $fillKey: Fill the key that does not exist in the array, default true. bool
Return Values
- Returns the resulting array.
Example :