Skip to content

Commit 16317db

Browse files
committed
docs: add :lines: 2-
1 parent 1508db8 commit 16317db

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

user_guide_src/source/helpers/array_helper.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Loading this Helper
1515
This helper is loaded using the following code:
1616

1717
.. literalinclude:: array_helper/001.php
18+
:lines: 2-
1819

1920
Available Functions
2021
===================
@@ -32,21 +33,25 @@ The following functions are available:
3233
and allows the use of a the '*' wildcard. Given the following array:
3334

3435
.. literalinclude:: array_helper/002.php
36+
:lines: 2-
3537

3638
We can locate the value of 'fizz' by using the search string "foo.buzz.fizz". Likewise, the value
3739
of baz can be found with "foo.bar.baz":
3840

3941
.. literalinclude:: array_helper/003.php
42+
:lines: 2-
4043

4144
You can use the asterisk as a wildcard to replace any of the segments. When found, it will search through all
4245
of the child nodes until it finds it. This is handy if you don't know the values, or if your values
4346
have a numeric index:
4447

4548
.. literalinclude:: array_helper/004.php
49+
:lines: 2-
4650

4751
If the array key contains a dot, then the key can be escaped with a backslash:
4852

4953
.. literalinclude:: array_helper/005.php
54+
:lines: 2-
5055

5156
.. note:: Prior to v4.2.0, ``dot_array_search('foo.bar.baz', ['foo' => ['bar' => 23]])`` returned ``23``
5257
due to a bug. v4.2.0 and later returns ``null``.
@@ -73,17 +78,20 @@ The following functions are available:
7378
from, e.g., the ``find()`` function of a model:
7479

7580
.. literalinclude:: array_helper/006.php
81+
:lines: 2-
7682

7783
Now sort this array by two keys. Note that the method supports the dot-notation
7884
to access values in deeper array levels, but does not support wildcards:
7985

8086
.. literalinclude:: array_helper/007.php
87+
:lines: 2-
8188

8289
The ``$players`` array is now sorted by the 'order' value in each players'
8390
'team' subarray. If this value is equal for several players, these players
8491
will be ordered by their 'position'. The resulting array is:
8592

8693
.. literalinclude:: array_helper/008.php
94+
:lines: 2-
8795

8896
In the same way, the method can also handle an array of objects. In the example
8997
above it is further possible that each 'player' is represented by an array,
@@ -101,16 +109,19 @@ The following functions are available:
101109
as separators for the keys.
102110

103111
.. literalinclude:: array_helper/009.php
112+
:lines: 2-
104113

105114
On inspection, ``$flattened`` is equal to:
106115

107116
.. literalinclude:: array_helper/010.php
117+
:lines: 2-
108118

109119
Users may use the ``$id`` parameter on their own, but are not required to do so.
110120
The function uses this parameter internally to track the flattened keys. If users
111121
will be supplying an initial ``$id``, it will be prepended to all keys.
112122

113123
.. literalinclude:: array_helper/011.php
124+
:lines: 2-
114125

115126
.. php:function:: array_group_by(array $array, array $indexes[, bool $includeEmpty = false]): array
116127
@@ -128,10 +139,13 @@ The following functions are available:
128139
.. literalinclude:: array_helper/012.php
129140

130141
We want to group them first by "gender", then by "hr.department" (max depth = 2).
142+
:lines: 2-
131143
First the result when excluding empty values:
132144

133145
.. literalinclude:: array_helper/013.php
134-
146+
:lines: 2-
147+
135148
And here the same code, but this time we want to include empty values:
136149

137150
.. literalinclude:: array_helper/014.php
151+
:lines: 2-

0 commit comments

Comments
 (0)