Skip to content

Commit 0152ed4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents a6f72ed + 18f5aac commit 0152ed4

File tree

4 files changed

+140
-15
lines changed

4 files changed

+140
-15
lines changed

docs/SUMMARY.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@
1515

1616
* [General information](object-oriented-methods/general-information.md)
1717

18-
## Validating array
18+
## Traversing array
1919

20-
* [check](validating-array/check.md)
21-
* [isEmpty](validating-array/isempty.md)
22-
* [isNested](validating-array/isnested.md)
23-
* [isArrayOfArrays](validating-array/isarrayofarrays.md)
24-
* [isAssoc](validating-array/isassoc.md)
25-
* [isUnique](validating-array/isunique.md)
26-
* [isNumeric](validating-array/isnumeric.md)
27-
* [hasKeys](validating-array/haskeys.md)
20+
* [Finding](traversing-array/finding.md)
21+
* [Iterating](traversing-array/iterating.md)
2822

2923
## Manipulating array
3024

3125
* [Mapping](manipulating-array/mapping.md)
3226
* [Filtering](manipulating-array/filtering.md)
3327
* [Grouping](manipulating-array/grouping.md)
34-
* [Finding](manipulating-array/finding.md)
3528
* [Sorting](manipulating-array/sorting.md)
3629
* [Computations](manipulating-array/computation.md)
3730
* [Flattening](manipulating-array/flattening.md)
3831

32+
## Validating array
33+
34+
* [check](validating-array/check.md)
35+
* [isEmpty](validating-array/isempty.md)
36+
* [isNested](validating-array/isnested.md)
37+
* [isArrayOfArrays](validating-array/isarrayofarrays.md)
38+
* [isAssoc](validating-array/isassoc.md)
39+
* [isUnique](validating-array/isunique.md)
40+
* [isNumeric](validating-array/isnumeric.md)
41+
* [hasKeys](validating-array/haskeys.md)
42+
3943
## Utility methods
4044

4145
* [pack](utility-methods/pack.md)

docs/object-oriented-methods/general-information.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ Arr::obj(array|ArrayAccess $array = [])
1515

1616
For chaining just call standard `Arr` methods without first parameter \(array or ArrayAccess object\).
1717

18-
As a convenience `ArrObj` contains PHPDoc definitions for every available method, so you don't need to guess their parameters and quickly jump to the corresponding `Arr` method.
18+
As a convenience `ArrObj` contains PHPDoc definitions for every available method, so you don't need to guess their parameters.
1919

20-
To obtain array from object just call `getArray()` as the final method of a chain.
20+
Also you can quickly jump to the corresponding `Arr` method by using `@see` tag.
21+
22+
To obtain array from object just call `getArray()` as the final method in chain.
2123

2224
### Examples
2325

docs/manipulating-array/finding.md renamed to docs/traversing-array/finding.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Find array \(or iterable object\) element\(s\) that match specified condition.
1616

1717
| Constant name | Description |
1818
| :--- | :--- |
19-
| FIND\_RETURN\_VALUE | Return value of array element matching find condition |
20-
| FIND\_RETURN\_KEY | Return key of array element matching find condition |
21-
| FIND\_RETURN\_ALL | Return array of all values \(preserving original keys\) of array elements matching find condition |
19+
| FIND\_RETURN\_VALUE | Return first value of an array that match find condition |
20+
| FIND\_RETURN\_KEY | Return first key of an array that match find condition |
21+
| FIND\_RETURN\_ALL | Return array of all values \(preserving original keys\) that match find condition |
2222

2323
#### Examples
2424

docs/traversing-array/iterating.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Iterating
2+
3+
## each
4+
5+
#### Definition
6+
7+
```php
8+
Arr::each(array|Iterator|IteratorAggregate $iterable, callable $callback, int $mode = self::EACH_VALUE): array|Iterator|IteratorAggregate
9+
```
10+
11+
#### Description
12+
13+
Traverse through array or iterable object and call callback for each element \(ignoring the result\).
14+
15+
#### Modes
16+
17+
<table>
18+
<thead>
19+
<tr>
20+
<th style="text-align:left">Constant name</th>
21+
<th style="text-align:left">Description</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
<tr>
26+
<td style="text-align:left">EACH_VALUE</td>
27+
<td style="text-align:left">Iterate using callback in form of <code>function($value)</code>
28+
</td>
29+
</tr>
30+
<tr>
31+
<td style="text-align:left">EACH_KEY_VALUE</td>
32+
<td style="text-align:left">Iterate using callback in form of <code>function($key, $value)</code>
33+
</td>
34+
</tr>
35+
<tr>
36+
<td style="text-align:left">EACH_VALUE_KEY</td>
37+
<td style="text-align:left">Iterate using callback in form of <code>function($value, $key)</code>
38+
</td>
39+
</tr>
40+
<tr>
41+
<td style="text-align:left">EACH_VALUE_KEYS_LIST</td>
42+
<td style="text-align:left">
43+
<p>Iterate using callback in form of <code>function($value, $key1, $key2, ...)</code>
44+
<br
45+
/>
46+
</p>
47+
<p><b>Only for array</b> <code>$iterable</code>
48+
</p>
49+
</td>
50+
</tr>
51+
<tr>
52+
<td style="text-align:left">EACH_KEYS_ARRAY_VALUE</td>
53+
<td style="text-align:left">
54+
<p>Iterate using callback in form of <code>function(array $keys, $value)</code>
55+
</p>
56+
<p><b><br />Only for array</b> <code>$iterable</code>
57+
</p>
58+
</td>
59+
</tr>
60+
</tbody>
61+
</table>#### Examples
62+
63+
```php
64+
$array = [
65+
1 => [
66+
2 => 'a',
67+
3 => 'b',
68+
4 => [
69+
5 => 'c',
70+
],
71+
],
72+
'test' => 'd',
73+
];
74+
75+
// Value only - using default EACH_VALUE mode
76+
Arr::each($array, function ($value) {
77+
print_r($value);
78+
// [ 2 => 'a', ...]
79+
// 'd'
80+
});
81+
82+
// Key, Value
83+
Arr::each($array, function ($key, $value) {
84+
echo "{$key}: \t\t";
85+
print_r($value);
86+
// 1: [2 => 'a', ...]
87+
// test: 'd'
88+
}, Arr::EACH_KEY_VALUE);
89+
90+
// Value, Key
91+
Arr::each($array, function ($value, $key) {
92+
echo "{$key}: \t\t";
93+
print_r($value);
94+
// 1: [2 => 'a', ...]
95+
// test: 'd'
96+
}, Arr::EACH_VALUE_KEY);
97+
98+
// Value, Keys list
99+
Arr::each($array, function ($value, ...$keys) {
100+
echo implode('.', $keys) . ': \t\t';
101+
print_r($value);
102+
// 1.2: 'a'
103+
// 1.3: 'b'
104+
// 1.4.5: 'c'
105+
// test: 'd'
106+
}, Arr::EACH_VALUE_KEYS_LIST);
107+
108+
109+
// Keys array, value
110+
Arr::each($array, function (array $keys, $value) {
111+
echo implode('.', $keys) . ': \t\t';
112+
print_r($value);
113+
// 1.2: 'a'
114+
// 1.3: 'b'
115+
// 1.4.5: 'c'
116+
// test: 'd'
117+
}, Arr::EACH_KEYS_ARRAY_VALUE);
118+
```
119+

0 commit comments

Comments
 (0)