|
1 | 1 | # Quorum Array Functions
|
2 | 2 |
|
3 |
| -[](https://github.com/QuorumCollection/ArrayFunctions/actions/workflows/ci.yml) |
| 3 | +[](https://packagist.org/packages/quorum/array-functions) |
| 4 | +[](https://packagist.org/packages/quorum/array-functions) |
| 5 | +[](https://github.com/QuorumCollection/ArrayFunctions/actions?query=workflow%3ACI) |
| 6 | + |
4 | 7 |
|
5 | 8 | A collection of global `array_*` functions appending to the native PHP set.
|
6 | 9 |
|
7 |
| -- `array_flatten( array $array, $allow_duplicates = false )` |
8 |
| - - Given an array, find all the values recursively. |
9 |
| -- `array_blend( array $arrays, array $keys = null )` |
10 |
| - - Given an array of arrays, merges the array's children together. |
11 |
| -- `array_key_array( array $arrays, $key )` |
12 |
| - - Given an array of similarly keyed arrays, returns an array of only the values of the key. |
13 |
| -- `array_keys_array( array $arrays, $keys )` |
14 |
| - - Given an array of similarly keyed arrays, returns an array of only the selected keys. |
15 |
| -- `array_key_refill( array $array, $keys, $fill = array() )` |
16 |
| - - Given a keyed array, fills any missing values. |
| 10 | +## Requirements |
| 11 | + |
| 12 | +- **php**: >=5.3.0 |
| 13 | + |
| 14 | +## Installing |
| 15 | + |
| 16 | +Install the latest version with: |
| 17 | + |
| 18 | +```bash |
| 19 | +composer require 'quorum/array-functions' |
| 20 | +``` |
| 21 | + |
| 22 | +## Array Functions |
| 23 | + |
| 24 | +### Function: \array_flatten |
| 25 | + |
| 26 | +```php |
| 27 | +function array_flatten(array $array [, $allow_duplicates = false]) |
| 28 | +``` |
| 29 | + |
| 30 | +##### Parameters: |
| 31 | + |
| 32 | +- ***array*** `$array` - The Array to be Flattened |
| 33 | +- ***bool*** `$allow_duplicates` - Should the array allow duplicates |
| 34 | + |
| 35 | +##### Returns: |
| 36 | + |
| 37 | +- ***array*** - The resulting array or NULL on failure |
| 38 | + |
| 39 | +Given an array, find all the values recursively. |
| 40 | + |
| 41 | +### Function: \array_blend |
| 42 | + |
| 43 | +```php |
| 44 | +function array_blend(array $arrays [, array $keys = null]) |
| 45 | +``` |
| 46 | + |
| 47 | +##### Parameters: |
| 48 | + |
| 49 | +- ***array*** `$arrays` - An array of arrays. |
| 50 | +- ***array*** | ***null*** `$keys` - The merged array. |
| 51 | + |
| 52 | +##### Returns: |
| 53 | + |
| 54 | +- ***array*** - The resulting blended array |
| 55 | + |
| 56 | +Given an array of arrays, merges the array's children together. |
| 57 | + |
| 58 | +### Function: \array_key_array |
| 59 | + |
| 60 | +```php |
| 61 | +function array_key_array(array $arrays, $key) |
| 62 | +``` |
| 63 | + |
| 64 | +##### Parameters: |
| 65 | + |
| 66 | +- ***array*** `$arrays` - An array of similarly keyed arrays |
| 67 | +- ***int*** | ***string*** `$key` - The desired key |
| 68 | + |
| 69 | +##### Returns: |
| 70 | + |
| 71 | +- ***array*** - The flattened array |
| 72 | + |
| 73 | +Given an array of similarly keyed arrays, returns an array of only the values of the key. |
| 74 | + |
| 75 | +### Function: \array_keys_array |
| 76 | + |
| 77 | +```php |
| 78 | +function array_keys_array(array $arrays, $keys) |
| 79 | +``` |
| 80 | + |
| 81 | +##### Parameters: |
| 82 | + |
| 83 | +- ***array*** `$arrays` - An array of similarly keyed arrays |
| 84 | +- ***array*** | ***int*** | ***string*** `$keys` - The key or array of keys to return |
| 85 | + |
| 86 | +##### Returns: |
| 87 | + |
| 88 | +- ***array*** - The array of arrays with just the selected keys |
| 89 | + |
| 90 | +Given an array of similarly keyed arrays, returns an array of only the selected keys. |
| 91 | + |
| 92 | +### Function: \array_key_refill |
| 93 | + |
| 94 | +```php |
| 95 | +function array_key_refill(array $array, array $keys [, $fill = array()]) |
| 96 | +``` |
| 97 | + |
| 98 | +##### Parameters: |
| 99 | + |
| 100 | +- ***array*** `$array` - A Keyed array |
| 101 | +- ***array*** `$keys` - The keys that must exist |
| 102 | +- ***mixed*** `$fill` - The desired value to fill with |
| 103 | + |
| 104 | +##### Returns: |
| 105 | + |
| 106 | +- ***array*** |
| 107 | + |
| 108 | +Given a keyed array, fills any missing values. |
0 commit comments